Renames one or more database accounts.
Syntax
RENAME USER old_user TO new_user
[, old_user TO new_user] ...Parameters
| Parameter | Description |
|---|---|
old_user | The existing account name to rename. |
new_user | The new account name. |
To rename multiple accounts in a single statement, separate each rename pair with a comma.
Example
The following example renames account2 to account_2, then verifies the rename by querying the mysql.user system table.
-- Rename the account
RENAME USER account2 TO account_2;
-- Verify the rename
SELECT User, Host, Password FROM mysql.user;Expected output:
+----------+-----+-------------------------+
| User | Host| Password |
+----------+-----+-------------------------+
| account2 | % | *61f3777f02386598cda**** |
| account_2| % | *0fe79c07e168cabc99b**** |
+----------+-----+-------------------------+