Purpose
This statement is used to modify the username of a user who logs in to OceanBase Database.
Note
You must have the global CREATE USER privilege to use this statement to rename a user.
Syntax
RENAME USER
'old_user_name' TO 'new_user_name'
[,'old_user_name' TO 'new_user_name'...]
Parameters
| Parameter | Description |
|---|---|
| old_user_name | The original username. |
| new_user_name | The new username. The username must be less than or equal to 16 bytes in length. |
| 'old_user_name' TO 'new_user_name' | The new username. When you modify multiple usernames, separate them with commas (,). The privileges of the new and old users remain consistent before and after the modification. |
Examples
Before the modification, execute the following statement to view the user.
obclient> SELECT user FROM mysql.user;The query result is as follows:
+-----------+ | user | +-----------+ | root | | admin | | sqluser01 | | sqluser02 | +-----------+ 4 rows in setExecute the following statement to rename the username of the
sqluser01user toobsqluser01.obclient> RENAME USER 'sqluser01' TO 'obsqluser01';After the modification, execute the following statement 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.
