This guide explains how to restore user database access. If a database user loses access to databases, you can restore their database grants using the ‘restoregrants’ utility or by updating the user’s password.
Follow the steps:
- How to use the ‘restoregrants’ script:
- Use one of the subsequent commands from the command line to use restoregrants script to 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
- An explanation of the variables used in the overhead example:
- $cpuser: Refers to the cPanel username of the person who lost their database access.
- $dbuser: The database user who can restore 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 associated with the cPanel account.
- $type: Refers to the type of database.
- mysql: MySQL®.
- pg: PostgreSQL®.
- Use one of the subsequent commands from the command line to use restoregrants script to restore the user’s database access:
- Update Password:
The ‘restoregrants’ script may not always succeed in restoring database access. If the script fails, the cPanel user or the WHM user managing the account (such as a system administrator or reseller) can restore grants by resetting the cPanel account’s password.- If you are a cPanel user, you can restore grants by following these steps:
- Go to the Password & Security interface in cPanel via cPanel >> Home >> Preferences >> Password & Security.
- Select Allow MySQL password change.
- Enter your old password in the Old Password text box.
- Enter a new password in both the New Password and New Password (again) text boxes.
- Click “Change your password now!”.
- Go to the Password & Security interface in cPanel via cPanel >> Home >> Preferences >> Password & Security.
- If you are a Server Administrator or Reseller, you can restore grants by following these steps:
- Access the List Accounts interface in WHM via WHM >> Home >> Account Information >> List Accounts.
- Click the “+ link” next to the relevant account.
- Select Sync MySQL password with account password.
- Enter a new password in the Change Password text box.
- Click Change.
- Access the List Accounts interface in WHM via WHM >> Home >> Account Information >> List Accounts.
- If you are a cPanel user, you can restore grants by following these steps:
This method allows you to restore user database access. If you need further assistance, don’t hesitate to contact our support team.
Need to manage user permissions? Check out our guide on How to Grant all Privileges to the User in cPanel