Reset MySQL Forgotten root User Password
If you forgot MySQL root user password then you can recover the password, if you have root access to base Linux machine. Credentials will be stored under MySQL database in MySQL server. In this article we are going to see How To Reset MySQL forgotten root user password, Step by Step Guide Red Hat/Centos.
How to Reset MySQL Forgotten root User Password
Stop the MySQL service, ensure that nobody is using MySQL before stopping.
$ mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
# service mysqld stop Stopping mysqld: [ OK ]
Start MySQL service in safe mode without grant tables (Not ask for credentials)
180417 23:36:56 mysqld_safe Logging to '/var/log/mysqld.log'. 180417 23:36:56 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Now access the MySQL instance by using below command
# mysql -u root
use mysql; update user set password=PASSWORD("mysql") where user='root'; flush privileges; quit
again stop MySQL services and start in normal mode
# service mysqld stop 180417 23:42:36 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended Stopping mysqld: [ OK ] [1]+ Done mysqld_safe --skip-grant-tables
Starting in normal mode
# service mysqld start
That’s it Now accessing the MySQL using new password. Reset MySQL forgotten root user password is very simple steps as mentioned above.
Related Articles
RHEL 7 root password reset procedure
Thanks for your wonderful Support and Encouragement