How to reset root password of MySQL on Linux

For some reason, sometimes you may forget the password to log in to MySQL with the root account to administer and configure the database. For that reason, in this article TopHostCoupon will guide you to reset this password.

Reset root password mysql

Step 1: Login SSH to the server as root

To reset the MySQL root password you must log in to SSH as root.

Step 2: Stop the running MySQL service

With CentOS and Fedora

service mysqld stop

With Ubuntu and Debian

service mysql stop

Step 3: Run MySQL in safe_mode

You use the following command, if Ubuntu, use safe_mysqld

mysqld_safe –skip-grant-tables &

Step 4: Reset MySQL root password

Type the following commands one by one, replacing yournewpassword with the new MySQL password

mysql -u root

Then you do the following:

#mysql> use mysql;
#mysql> UPDATE user SET Password = PASSWORD (‘yournewpassword’) WHERE User=’root’;
#mysql> quit;

Step 5: Restart MySQL with the following command:

service mysqld start

So we have shown you how to reset MySQL’s root password, it’s that simple, isn’t it? Good luck!

About the Author: admin
The best hosting, domain and VPS servers coupon codes at help you save money when buying hosting, domain names, and servers.
You might like

Leave a Reply

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