How To Restore Database Grants On WHM cPanel?

When a database user loses his access to configured databases, you may need to restore that user’s grants to the database using the restoregrants utility on WHM.

First step you need to make is access your command line then use restoregrants to restore the user’s database access:

/usr/local/cpanel/bin/restoregrants –cpuser=$cpuser –db={mysql, pg} –dbuser=$dbuser

/usr/local/cpanel/bin/restoregrants –cpuser=$cpuser –db={mysql, pg} –all

Where:

  • $cpuser – is the cPanel username which has lost access to databases.
  • {mysql, pg} –  is the type of database: mysql for MySQL or pg for PostgreSQL.
  • $dbuser – is database user whose privileges you wish to restore. If you use –dbuser, the $dbuser variable will consist of the database user’s name. If you use –all, the script will restore grants for all of the database users that belong to the cPanel account.

How to update user’s password to restore database access on cPanel?

In certain circumstances, the restoregrants script may fail to restore access to the database.

In such case, either the cPanel or the WHM  account owner can reset the cPanel account’s password in order to restore grants by following the given steps.

For restoring grants from cPanel:

  1. Navigate to cPanel > Change Password.
  2. Select Allow MySQL password change.
  3. Change the password and click Change your password now.

Steps for server administrator i.e. the owner of WHM account:

  1. Navigate to WHM > List Accounts.
  2. Click + next to the appropriate account.
  3. Select Sync MySQL password with account password.
  4. Enter a new password into the Change Password box and click Change.

For online support email to system@sangkrit.net or download Personal App of System Administrator.

Leave a Reply