June 29, 2012
Reset lost mySQL root password without authenticating
First, confirm that there is a password set for Root by changing the phpMyAdmin configuation to allow login without password.
$ cd /usr/share/phpmyadmin/
$ grep -r AllowNoPassword .
$ sudo nano libraries/config.default.php &
- Find the allownopassword setting and change to true
Try to login at localhost/phpmyadmin. If fails, then password is set and you need to login without authenticating so you can reset it.
$ sudo /etc/init.d/mysql stop
$ sudo mysqld --skip-grant-tables --skip-networking &
$ mysql mysql -u root
Type in the following command and reset your password:
> UPDATE user SET password=PASSWORD('newpassword') WHERE user="root";
If you didn't go through the first step, to validate the changes simply type:
> FLUSH PRIVILEGES;
If you started MySQL manually (bypassing the authentication process), the server must be restarted:
$ /etc/init.d/mysql restart
Then visit localhost/phpmyadmin and test the password.
Posted by kkwaiser at June 29, 2012 12:52 PM