1. Home
  2. Knowledge Base
  3. Problems (EN)
  4. I lost my MySQL root password, how can I recover it ?

I lost my MySQL root password, how can I recover it ?

If you lose your MySQL root password, do as follows. First of all, stop MySQL:

# service mysql stop

Wait until MySQL shuts down. Then run:

# mysqld_safe --skip-grant-tables &

After that you will be able to login as root without a password:

#mysql -uroot mysql

In the MySQL command line prompt issue the following command:

UPDATE user SET password=PASSWORD("none") WHERE user="root"; FLUSH PRIVILEGES;

Stop the running MySQL instance:

# kill `ps aux | grep -e "--skip-grant" | grep -v grep | awk '{ print $2 }'`

Restart the MySQL service normally:

# service mysql start

At this time your root password is reset to “none” and MySQL will now know the privileges and you’ll be able to login with your new password:

# mysql -uroot -pnone mysql
Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support

Recent Discussions