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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.