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.
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> FLUSH PRIVILEGES;
#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!