Missing Mysql Users Restoration after CPanel Server Crash

You might be sometimes stuck in database user access during some unexpected events like a cPanel crash or a modification in password security level. Database restoregrants is a solution which can get you out this problem with some initial compromise on security.

For this, you have to uninstall the password validation plugin at first through the command terminal.

mysql -h localhost -u root -p
mysql>uninstall plugin validate_password;

At this level, you might be at an insecure state since passwords aren't validated upon requests to MySQL.

Next, you can restore the grants to the user through the utility command at the same terminal. Run the following command with the appropriate variables in place relative to your database;


for i in `ls -I \. -I \.\. -A /var/cpanel/users` ; do /usr/local/cpanel/bin/restoregrants --cpuser=$i  --db=mysql --all; done

After this step, you might consider synchronising these changes so that the dbstoregrants are updated into WHM and cPanel accounts. Use the following script to run the synchronisation:

for i in `ls -I \. -I \.\. -A /var/cpanel/users` ; do /usr/local/cpanel/bin/dbstoregrants $i ; done

Use the following table to refer to variables in the scripts above;


After this install the validation plugin again to restore the security level of your databases.

Post a Comment

0 Comments