Recover MySQL root Password in RHEL/CentOS

We can recover  MySQL database server password with the following steps.

1.Stop the MySQL service by using below command.

service mysqld stop
/etc/init.d/mysqld stop


2.Now Start the MySQL server without password by using

 mysqld_safe --skip-grant-tables & 


3.Now Connect to mysql using mysql -u root  command


4. Now Set a new MySQL root user password by typing below commands in command prompt.

use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;


5.Now stop mysql service


6.Now start the mysql service using service mysqld start or /etc/init.d/myqld start and try to connect to mysql using mysql -u root -p with new password.

This entry was posted in Linux, Mysql. Bookmark the permalink.

Leave a Reply

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

You are commenting using your 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