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
mysql root password

mysql root password

use mysql;
update user set password=PASSWORD("mysql") where user='root';
flush privileges;

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/ 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

More Video Tutorials

Thanks for your wonderful Support and Encouragement

Ravi Kumar Ankam

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

Leave a Reply

Your email address will not be published. Required fields are marked *