If a database user loses access to databases, you can restore their grants using the restoregrants utility. This guide covers two methods: using the command-line script or resetting the account password to trigger automatic grant restoration.
How to Restore Database Access
-
Step 1: Run the restoregrants script
Execute one of the following commands from the command line, depending on whether you want to restore a specific database user or all users:
/usr/local/cpanel/bin/restoregrants --cpuser=$cpuser --db=$type --dbuser=$dbuser /usr/local/cpanel/bin/restoregrants --cpuser=$cpuser --db=$type --allThe variables are:
$cpuser: The cPanel username experiencing a loss of access to their databases.$dbuser: The database user for whom privileges need restoration (when using--dbuserflag). If using--allflag, the script restores grants for all database users associated with the cPanel account.$type: The database type —mysqlfor MySQL® orpgfor PostgreSQL®.
Alternative Method: Password Update
If the restoregrants script fails to restore database access, either the cPanel user or the WHM user overseeing the account (reseller or system administrator) can reset the cPanel account's password to restore grants.
For cPanel Users
-
Step 1: Navigate to Password and Security
Go to cPanel's Password and Security interface (cPanel » Home » Preferences » Password & Security).
-
Step 2: Enable MySQL password change
Enable "Allow MySQL password change."
-
Step 3: Enter old password
Input the old password in the Old Password text box.
-
Step 4: Enter new password
Enter a new password in both the New Password and New Password (again) text boxes.
-
Step 5: Change password
Click "Change your password now."
For Server Administrators or Resellers
-
Step 1: Access List Accounts
Go to WHM's List Accounts interface (WHM » Home » Account Information » List Accounts).
-
Step 2: Select the account
Click the + link next to the relevant account.
-
Step 3: Sync MySQL password
Choose "Sync MySQL password with account password."
-
Step 4: Enter new password
Input a new password in the Change Password text box.
-
Step 5: Apply changes
Click "Change."