How to Restore Database Access of Users?

In the event of a database user losing access to databases, you can regain the user's grants to the database using the restoregrants utility.

The restoregrants script:

To employ the restoregrants script for restoring the user's database access, execute one of the following commands from the command line:

1

2

/usr/local/cpanel/bin/restoregrants --cpuser=$cpuser --db=$type --dbuser=$dbuser

/usr/local/cpanel/bin/restoregrants --cpuser=$cpuser --db=$type  --all

The provided examples utilize the following variables:

  • $cpuser: The cPanel username experiencing a loss of access to their databases.

  • $dbuser: The database user for whom privileges need restoration.

    • If the --dbuser flag is used, $dbuser signifies the specific database user.

    • If the --all flag is used, the script restores grants for all database users associated with the cPanel account.

  • $type: The database type, which can be:

    • mysql: MySQL®.

    • pg: PostgreSQL®.

 

Password Update:

In specific scenarios, the restore grants script may encounter difficulties in restoring database access. If the script fails, either the cPanel user or the WHM user overseeing the account (the reseller or system administrator) has the option to reset the cPanel account's password for grant restoration.

Steps for cPanel User to Restore Grants:

  1. Navigate to cPanel's Password and Security interface (cPanel » Home » Preferences » Password & Security).

  2. Enable "Allow MySQL password change."

  3. Input 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 Server Administrator or Reseller to Restore Grants:

  1. Go to WHM's List Accounts interface (WHM » Home » Account Information » List Accounts).

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

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

  4. Input a new password in the Change Password text box.

  5. Click "Change."


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 909