How do I recover a lost MySQL password? Print

  • 1385

It is not possible to recover a lost mysql password since they are encrypted. But it can always be changed or reset.

To change the root mysql password, follow these steps:

1) Stop mysql by executing as root in the command line: service mysql stop

2) Start mysql without the privileges system, execute: mysqld_safe --skip-grant-tables &

3) Open the mysql console by executing: mysql

4) Run the following queries (replace the root password with your desired password)

UPDATE mysql.user SET Password=PASSWORD('yourpassword') WHERE User='root';

FLUSH PRIVILEGES;

5) exit the mysql console and stop mysql: service mysql stop

6) Start mysql by executing: service mysql start

Now the new password is in place.

 


Was this answer helpful?

« Back