How to Reset MySQL Root Password and Restore Database Grants in cPanel Server?

Last modified: July 29, 2020
You are here:
  • KB Home
  • Mysql
  • How to Reset MySQL Root Password and Restore Database Grants in cPanel Server?
Estimated reading time: 1 min

We can reset mysql root password via command line in Linux server. Also, we can use this method in cPanel server, but there is some problem WHM will not know the new root mysql password and database features will fail with access denied from mysql. So in cPanel server, you will want to reset the mysql root password through WHM.

Please refer the following link to how to reset MySQL root password in Linux server via command line. https://www.Fastycloud.com/tips/kb/how-to-recover-the-mysql-root-password/

 

In this tutorial will help you to know how to reset MySQL root password via WHM.

1) Login to WHM as a root user.

2) From there select “SQL Services”.

Reset MySQL password

 

3) Then click on the button “MySQL Root Password”.

Reset MySQL password

 

 

4) Now enter the new password and click on “Change Password” button.

Reset MySQL password

 

Restore Database Grants.

The cPanel provides “restoregrants” utility to restore the user’s database access.

1) Login to the server as a root user via SSH.

2) Run either of the following commands from command line.

/usr/local/cpanel/bin/restoregrants –cpuser=$cpuser –db={mysql, pg} –dbuser=$dbuser

/usr/local/cpanel/bin/restoregrants –cpuser=$cpuser –db={mysql, pg}  –all

$cpuser is the cPanel username that has lost access to databases.

{mysql, pg} is the type of database: mysql for MySQL or pg for PostgreSQL

$dbuser >> The database user whose privileges you that wish to restore. If you use the –dbuser flag, the $dbuser variable will consist of the database user’s name. If you use the –all flag, the script will restore grants for all of the database users that the cPanel account owns.

 

If you need any further help please do reach our support department.

Was this article helpful?
Dislike 0
Views: 9