How to Restore a User’s Database Access in cPanel

Overview

In case, the databases of database users disappear then it can be restored the user’s grants to the database with the restoregrants utility.

The Restoregrants script

To access the restoregrants script for restoring the user’s database access, run one of the following commands from the command line:

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

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

Below mentioned are the examples of variables:

$cpuser – It’s a cPanel username that lost access to the databases.

$dbuser – The database user who wants to restore the database.

  • If the user utilizes the –dbuserflag, $dbuser showcase the database user.
  • If the user utilizes the –allflag, then the script redeems permission for all of the database users that are associated with the cPanel account.

$type — The type of database:

  • mysql— MySQL®.

  • pg— PostgreSQL®.

Update password

In some cases, the restoregrants scripts might fail to restore access to the database.

If such a situation occurs, either the cPanel user or the WHM user who owns the account (the reseller or system administrator) can reset the cPanel account’s password to restore the grants.

The cPanel user can restore the grants with the following steps:

  • Head out for cPanel’s Password and Security interface (cPanel » Home » Preferences » Password & Security).
  • Opt for Allow MySQL password change
  • Type the old password in the old password text box.
  • Enter a new password in the New Password and New Password (again) text boxes.
  • Click on Change your password now.

Steps to restore grants for server administrators or resellers are mentioned below:

  • Navigate the WHM’s List Accounts interface (WHM » Home » Account Information » List Accounts).
  • Press the + link next to the appropriate account.
  • Select Sync MySQL password with the account password.
  • Enter the new password in the change password text box.
  • Click the Change button.

Leave a Reply