How to Restore Database Grants
Overview
If a database user loses access to databases, you can restore their grants to the database using the restoregrants
utility.
Restoring Database User Access
To restore a user's database access, execute one of the following commands from the command line:
|
|
The variables used in the commands are described in the table below:
Variable | Description |
---|---|
$cpuser |
The cPanel username that has lost access to databases. |
{mysql, pg} |
The type of database: mysql for MySQL® or pg for PostgreSQL®. |
$dbuser |
The database user whose privileges you wish to restore. If you use the --dbuser flag, the $dbuser variable will represent the database user’s name. If you use the --all flag, the script will restore grants for all database users owned by the cPanel account. |
Alternative Method: Resetting cPanel User Password
In some circumstances, the restoregrants
script may fail to restore database access. Should this occur, either the cPanel user or the WHM user who owns the account can reset the cPanel account’s password to restore the grants.
- cPanel users can reset their account passwords via cPanel’s Password & Security interface (cPanel » Home » Preferences » Password & Security).
- WHM users can reset the password through WHM’s List Accounts interface (WHM » Home » Account Information » List Accounts).