User Tools

Site Tools


mysql:password_recovery

MySQL - Password Recovery

If you've forgotten your root password, you'll need Linux Root login to reset your MySQL root password. Here is the steps for resetting forgotten MySQL root password.

First login to your Linux box as a root user, and stop the mysqld daemon.

service mysqld stop

Now, start the mysqld daemon without the grant table bypassing authentication.

mysqld_safe --skip-grant-tables &

The mysqld daemon should have started. Now login as a root user without the password.

mysql -u root
mysql> use mysql

Reset the root user password.

mysql> update user set Password=PASSWORD('new-password') where user='root';
mysql> flush privileges;
mysql> exit;

Restart the mysqld daemon, so that the new password will take into effect.

service mysqld restart

Other methods to recover the MySQL root password

/var/lib/mysql/mysql-pass-recover
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;

Restart mysql with new init file

chown mysql:mysql /var/lib/mysql/mysql-pass-recover
/etc/rc.d/rc.mysqld stop
sleep 5
killall mysqld; killall mysqld; killall mysqld; killall mysqld;
sleep 5
mysqld_safe --init-file=/var/lib/mysql/mysql-pass-recover &
sleep 5
killall mysqld; killall mysqld; killall mysqld; killall mysqld;
sleep 5
/etc/rc.d/rc.mysqld start
mysql/password_recovery.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki