Summary
If a database user experiences a loss of access to databases, you can utilize the restoregrants utility to reinstate the user's database grants. Another method is to update the password.
How to use the restoregrants script:
Execute one of the following commands from the command line to employ the restoregrants script and restore the user's database access:
/usr/local/cpanel/bin/restoregrants --cpuser=$cpuser --db=$type --dbuser=$dbuser
/usr/local/cpanel/bin/restoregrants --cpuser=$cpuser --db=$type --all
Variables used in the preceding example are described as follows:
-
$cpuser — Denotes the cPanel username of the user who lost database access.
-
$dbuser — Represents the database user capable of restoring the database. If you use the --dbuser flag, $dbuser describes the database user.
-
If you use the --all flag, the script restores permissions for all database users linked to the cPanel account.
-
$type — Indicates the type of database:
-
mysql — MySQL®.
-
pg — PostgreSQL®.
How to Use the Update Password Method:
The restoregrants script may encounter difficulties in restoring database access under certain conditions. If the script fails, the cPanel or WHM user overseeing the account (either the system administrator or the reseller) can rectify this by resetting the cPanel account's password.
Procedures for a cPanel user to restore grants:
If you are a cPanel user, follow these steps to restore grants:
-
Access the Password and Security interface in cPanel by navigating to cPanel >> Home >> Preferences >> Password & Security.
-
Choose "Allow MySQL password change."
-
Enter the old password in the "Old Password" text box.
-
Provide a new password in both the "New Password" and "New Password (again)" text boxes.
-
Click on "Change your password now."
Procedures for a WHM User to Restore Grants:
If you are a Server Administrator or Reseller, follow these steps to restore grants:
-
Access WHM's List Accounts interface via WHM >> Home >> Account Information >> List Accounts.
-
Click the + link next to the appropriate account.
-
Choose the "Sync MySQL password with account password" option.
-
Enter a new password in the "Change Password" text box.
-
Click on "Change."
Congratulations, you have successfully restored database access for users!