August 12, 2012 by harshalvaidya
Resetting MySQL Password
Initially login to server and stop the MySQL service on server. the best practice is to execute
# killall -9 mysqld (before stopping service)
Once the MySQL process is killed, execute the following command:
This will run the MySQL process so you need to open another terminal to be able to reset the password. On the new terminal, you will now be able to login to MySQL to reset the password.
On the shell prompt of the new terminal, open the MySQL console:
mysql> use mysql;
mysql> UPDATE user SET Password=PASSWORD(‘YOUR_NEW_PASSWORD’) WHERE Host=’localhost’ AND User=’root’;
This will change the password for the user ‘root’. Kill the MySQL process running in the first terminal, and start the mysql services.
Try logging in to the MySQL console using the new password:
#mysql -uroot -p
You should now be able to use the new password for your MySQL.