Child pages
  • How to Restore Database Grants

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Include Page
LIB:_Version
LIB:_Version

Table of Contents
stylenone

Overview

If a database user loses access to databases, you can restore the user's grants to the database with the restoregrants utility.

Use the restoregrants utility to restore the user's database access

Execute either of the following commands from the command line:

Code Block
languagebash
/usr/local/cpanel/bin/restoregrants --cpuser=$cpuser --db={mysql, pg} --dbuser=$dbuser


Code Block
languagebash
/usr/local/cpanel/bin/restoregrants --cpuser=$cpuser --db={mysql, pg}  --all

The following table describes the variables in the example above:

VariableDescription
$cpuserThe cPanel username that has lost access to databases.
{mysql, pg}The type of database: mysql for MySQL® or pg for PostgreSQL®.
$dbuserThe database user whose privileges you that wish to restore. If you use the --dbuser flag, the $dbuser variable will consist of the database user's name. If you use the --all flag, the script will restore grants for all of the database users that the cPanel account owns.

How to update the cPanel user's password to restore database access

In certain circumstances, the restoregrants script may fail to restore database access. If this occurs, either the cPanel user or the WHM user who owns the account can reset the cPanel account's password to restore grants.

  • cPanel users can reset their account passwords in cPanel's Password & Security interface (cPanel >> Home >> Preferences >> Password & Security).
  • WHM users can reset the password in WHM's List Accounts interface (WHM >> Home >> Account Information >> List Accounts).

Additional documentation

Localtab Group


Localtab
activetrue
titleSuggested documentation

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel = "databases" and label = "whm" and space = currentSpace()


Localtab
titleFor cPanel users

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel = "databases" and label = "cpanel" and space = currentSpace()


Localtab
titleFor WHM users

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel = "databases" and label = "whm" and space in (currentSpace(),"CKB")


Localtab
titleFor developers

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel = "databases" and space = "DD"