How to Restore Database Access of Users?

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:

  1. Access the Password and Security interface in cPanel by navigating to cPanel >> Home >> Preferences >> Password & Security.

  2. Choose "Allow MySQL password change."

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

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

  5. 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:

  1. Access WHM's List Accounts interface via WHM >> Home >> Account Information >> List Accounts.

  2. Click the + link next to the appropriate account.

  3. Choose the "Sync MySQL password with account password" option.

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

  5. Click on "Change."

Congratulations, you have successfully restored database access for users!


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 191