Rename user in MySQL database

Rename user account in MySQL database

Syntax:
RENAME USER old_user TO new_user
    [, old_user TO new_user] ...

Example of Rename User in MySQL

RENAME USER 'hr'@'localhost' TO 'salesuser'@'127.0.0.1';

--Rename multiple user
RENAME USER     
    hr@localhost TO salesuser@localhost,
    scott@localhost TO orderuser@localhost;

Check the User present in MySQL

SELECT host, user
FROM mysql.user
WHERE user = 'salesuser' and host = 'localhost';

Leave a Reply