Howto reset MySQL root password

Yes, this is the probably what we all done before, and tons of blog tips are cached by Google, but I want to have my own note for this).

Well find your MySQL configuration file that is named my.cnf. You may use locate index search in your Linux box if you previously installed it as follows

$locate my.cnf

or use whereis command (Hey, I'm giving you 3 in 1 tip;):

$whereis mysql

open it with your favorite editor and and the following line to [mysqld] section:


Then restart mysql deamon with command like:

$sudo service mysql restart


$sudo /etc/init.d/mysql restart

or something specific for your distro. Now login to mysql with:

mysql -p

NB: just press enter when it asks you the password

and execute the following SQL command:

UPDATE mysql.user SET password = PASSWORD('newpassword') WHERE user = 'root' AND host = 'localhost';

if successful, go back to the shell (for ex. with Ctrl+C), remove recently added config entry and restart service again.

And that's it.

I used this russian article for reference:


10-05-2012 10:08: DeathStar
Thanks for the link to my original article. I am glad that it helped you.