View Categories

Reading Time: 2 min read

How to Restore User Database Access? #

How to Restore User Database Access? Summary
If a database user loses access, the restoregrants utility can be used to recover their database permissions. Another option is to update the password.

How to Utilize the restoregrants Script? #

Execute one of the following commands in the command line to utilize the restoregrants script for reestablishing 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

Explanation of the variables utilized in the previous example:

  • $cpuser

— Indicates the cPanel username that lost database access.

  • $dbuser

— The user authorized to restore the database.

  • If you use the 
  • --dbuser

flag,

  • $dbuser

detail the database user.

  • If you utilize the
  • --all 

flag, the script reinstates permissions for all database users linked to the cPanel account.

  • $type

— Indicates the type of database:

  • mysql

— MySQL®.

  • pg

— PostgreSQL®.

How to Utilize the Update Password Option? #

The restoregrants script might not succeed in restoring database access under certain conditions.

If the script fails, the cPanel user or the WHM user managing the account (system administrator or reseller) can restore grants by resetting the cPanel account password.

Steps for a cPanel user to restore grants:

How to Restore User Database Access

How to Restore User Database Access? cPanel users can follow these steps to restore grants: #

1] Navigate to the Password and Security section in cPanel via cPanel >> Home >> Preferences >> Password & Security.

2] Select Allow MySQL password change.

3] Enter the old password in the Old Password text box.

4] Enter a new password in both the New Password and New Password (again) text boxes.

5] Click Change your password now.

Steps for a WHM user to restore grants:

As a Server Administrator or Reseller, you can follow these steps to restore grants: How to Restore User Database Access? #

1]  Open WHM’s List Accounts interface via WHM >> Home >> Account Information >> List Accounts.

2]  Click the + link next to the relevant account.

3]  Select the Sync MySQL password with account password option.

4]  Enter a new password in the Change Password text box.

5] Click Change.

Congratulations, you have successfully restored database access for users!