If a MySQL administrator simply wants to change the user name or the host of an existing MySQL user account, but not the user account's privileges, an administrator can use this MySQL statement to do that easily.


Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

RENAME USER 'user'[@'host'] TO 'user'[@'host'][,...]


Use this MySQL statement to change the user name or the host of an existing user account. It does not change the user privileges or necessarily migrate any privileges to specific databases, events, stored routines, tables, triggers, or views in MySQL.


RENAME USER 'michaelzabalaoui'@'localhost' TO 'zabb'@'%',
'richardstringer'@'localhost' TO 'littlerichard'@'localhost';

In this example, the first user's username and host account in MySQL has been changed, which the second user's name only was changed.