Purpose
You can use this statement to change the username of a user that has logged on to OceanBase Database.
Note
To execute this statement, you must have the CREATE USER privilege.
Syntax
RENAME USER
'old_user_name' TO 'new_user_name'
[,'old_user_name' TO 'new_user_name'...];
Parameters
| Parameter | Description |
|---|---|
| old_user_name | The old username. |
| new_user_name | The new username. The username can contain up to 16 bytes in length. |
| ‘old_user_name’ TO ‘new_user_name’ | The operation to change the username. Multiple usernames must be separated with commas (,). User privileges remain unchanged after the username is changed. |
Examples
Before you change the username, execute the following statement to query the user.
The result is as follows:
obclient> SELECT user FROM mysql.user; +-----------+ | user | +-----------+ | root | | admin | | sqluser01 | | sqluser02 | +-----------+ 4 rows in setExecute the following statement to change the username of
sqluser01toobsqluser01.obclient> RENAME USER 'sqluser01' TO 'obsqluser01';After you change the username, execute the following statement to query the user.
The username of
sqluser01has been changed toobsqluser01.obclient> RENAME USER 'sqluser01' TO 'obsqluser01'; Query OK, 0 rows affected obclient> SELECT user FROM mysql.user; +-------------+ | user | +-------------+ | root | | admin | | obsqluser01 | | sqluser02 | +-------------+ 4 rows in set