Hosting Question? Find the Solution -

KNOWNHOST KNOWLEDGE BASE

Browse our Guides, Articles, and How-To's

How to reset the MySQL root password?

Category: cPanel
Tags: # # #

DBAs (Database Administrators) need to have root-level access to MySQL; sometimes, you might need to change the MySQL password for security or other reasons. In this article, you will learn how to reset the MySQL root password?


Using WHM Panel

1. First, login into WHM panel,

https://your-domain.com:2087 or https://IP-address: 2087 or https://server-hostname: 2087.

login-to-whm-panel

2. Navigate to SQL Services → MySQL Root Password.

change mysql root password

3. Enter the password  Click on Change Password.

enter new password for root mysql

3. Congratulations! You have successfully changed MySQL password for root.

how to change mysql root password

Using SSH

1. Login to SSH and run the following to login into MySQL as user root and enter the present MySQL’s root user password,

mysql -u root -p
login to mysql root with password

If did not configure any password for MySQL root user then run the following command and simply hit Enter,

login to mysql as root user

2. Run the following command to set the new password,

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MY-NEW-PASSWORD';

In the above command, we changed MySQL’s root user password to “MY-NEW-PASSWORD”; replace ‘MY-NEW-PASSWORD” with the desired password.

how to change mysql root password using cli

3. Next, run the following command to flush the privileges,

FLUSH PRIVILEGES;
FLUSH PRIVILEGES mysql user

Conclusion

We’ve gone over how to reset the MySQL root password for WHM and use the command-line interface. If you ever want to change the MySQL root password, you need to go through this article.

KnownHost offers 365 days a year, 24 hours a day, all 7 days of the week best in class technical support. A dedicated team ready to help you with requests should you need our assistance. You’re not using KnownHost for the best webhosting experience? Well, why not? Check with our Sales team to see what can KnownHost do for you in improving your webhosting experience.