In this guide, we will explain how to use the MySQL RENAME USER statement with syntax and examples.
Description
The RENAME USER statement is used to rename a user in the database.
Syntax
The syntax for the RENAME USER statement in MySQL is:
RENAME USER user_name TO new_name;
Parameters or Arguments
user_nameThe name of the user to rename in the MySQL database.new_nameThe new name to assign to the user.
Example
Let’s look at how to rename a user using the RENAME USER statement.
For example:
RENAME USER 'smithj'@'localhost' TO 'jane'@'localhost';
In this example, the RENAME USER statement would rename the user called smithj to jane in the database.
Rename more than one user
How can you rename more than one user at a time in MySQL? You can use the RENAME USER statement to rename multiple users by comma separating the user name values.
For example:
RENAME USER 'smithj'@'localhost' TO 'jane'@'localhost', 'andersonk'@'localhost' TO 'kyle'@'localhost';
This RENAME USER example would rename two users in MySQL. The first user called smithj would be renamed to jane and the second user called andersonk would be renamed to kyle.
Next Topic : Click Here
Pingback: MySQL: Procedures | Adglob Infosystem Pvt Ltd