Recover Reset MySql Root Password
February 3, 2010 Leave a comment
It has been a few weeks since I last touched the server and I couldn’t remember the root password for MySql. I’m lucky enough to find the following website, which tells me how to get around it.
http://blog.taragana.com/index.php/archive/how-to-recover-mysql-root-password/
The whole idea is very clever, all we need to do is to stop MySql process and start it without the permission mode. Then we can choose to reset the password and restart the MySql again.
$ sudo /etc/init.d/mysql stop
$ sudo mysqld_safe –skip-grant-tables &
$ mysql -u root
Now that we are in …
> use mysql
> UPDATE user SET password = PASSWORD(‘NEW-PASSWORD’) WHERE user = ‘root’;
> flush privileges;
> quit
Then re can restart the MySql and try to login with the new password.
$ sudo /etc/init.d/mysql restart
# mysql -u root -p