Purpose
This statement is used to modify the username of a user logging in to OceanBase AI Database.
Note
You must have the global CREATE USER privilege to rename a user using this command.
Syntax
RENAME USER
'old_user_name' TO 'new_user_name'
[,'old_user_name' TO 'new_user_name'...]
Parameters
Parameters |
Description |
|---|---|
| old_user_name | Old username. |
| new_user_name | New username. The username must be 16 bytes or less. |
| 'old_user_name' TO 'new_user_name' | Modify the username. When modifying multiple usernames, separate them with commas (,). The permissions of the new and old users remain the same before and after the modification. |
Examples
Before modification, execute the following command to view users.
obclient> SELECT user FROM mysql.user;The query result is as follows:
+-----------+ | user | +-----------+ | root | | admin | | sqluser01 | | sqluser02 | +-----------+ 4 rows in setRun the following command to change the username of the
sqluser01user toobsqluser01.obclient> RENAME USER 'sqluser01' TO 'obsqluser01';After modification, execute the following command to view the user.
obclient> SELECT user FROM mysql.user;The query result is as follows:
+-------------+ | user | +-------------+ | root | | admin | | obsqluser01 | | sqluser02 | +-------------+ 4 rows in setThe username of the
sqluser01user has been changed toobsqluser01.