MySQL root password recovery.

If you are stuck about a MySQL access or if you have lost the ROOT password.

  1. As Linux system root user stop the database process: /etc/init.d/mysql stop (or: service mysql stop)
  2. Start MySQL in safe mode and skip the use of the “grant tables”:
    /usr/bin/mysqld_safe --user=mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --datadir=/var/lib/mysql --skip-grant-tables --skip-networking ;
  3. Reset the MySQL root password: mysqladmin -u root flush-privileges password newpassword
  4. Stop MySQL running in safe mode: kill `cat /var/run/mysqld/mysqld.pid`
  5. Start MySQL: /etc/init.d/mysql start
  6. The new MySQL root password can now be used: mysql -u root -p
  7. Respond with the password: newpassword

Be the first to comment

Leave a Reply

Your email address will not be published.


*


*