Sunday, March 9, 2008

Reset Forgotten MySQL Root Password

Have you ever forgotten the root password on one of your MySQL servers? No? Well maybe I’m not as perfect as you. This is a quick how to reset your MySQL root password. It does require root access on your server.

First things Log in as root and stop the mysql daemon. Now lets start up the mysql daemon and skip the grant tables which store the passwords.

mysqld_safe --skip-grant-tables

You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password.

mysql --user=root mysql
update user set Password=PASSWORD('new-password');
flush privileges;
exit;


Now kill your running mysqld, then restart it normally. You should be good to go. Try not to forget your password again.

No comments:

Post a Comment