Lost MySQL root password?

Ok, if this is your only problem this little trick will show how to recover your root password.

Proceed as follows.

  • Stop the db engine

/etc/init.d/mysql stop

  • Restart the daemon

/usr/bin/mysqld_safe –skip-grant-tables &

  • Go to the MySQL interactive command

mysql -h your_hostname mysql

  • Change the password with the GRANT command

GRANT ALL PRIVILEGES ON * to root@localhost IDENTIFIED BY ‘passwd’;
FLUSH PRIVILEGES;

Maybe it should be better to flush privileges from mysqladmin:

mysqladmin -h localhost flush-privileges

That’s it. Now try to login as usual.

References:

Leave a Reply

You must be logged in to post a comment.