How to restoregrants to restore the user's database access

restoregrants to restore the user's database access

Execute one of the following commands from the command line:
1
/usr/local/cpanel/bin/restoregrants --cpuser=$cpuser --db={mysql, pg} --dbuser=$dbuser
1
/usr/local/cpanel/bin/restoregrants --cpuser=$cpuser --db={mysql, pg}  --all
The following table explains the variables in the example above:
This variable:
Stands for:
$cpuserThe cPanel username which has lost access to databases.
{mysql, pg}The type of database: mysql for MySQL or pg for PostgreSQL.
$dbuserThe 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 the cPanel user's password to restore database access

In certain circumstances, the restoregrants script may fail to restore access to the database.
If this occurs, either the cPanel user or the WHM user who owns the account (that is, the reseller or system administrator) can reset the cPanel account's password to restore grants.
The cPanel user can perform the following actions:
  1. Navigate to cPanel > Change Password.
  2. Select Allow MySQL password change.
  3. Change the password and click Change your password now.
The server administrator or reseller can perform the following actions:
  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.

Post a Comment

1 Comments

  1. For all users in a cpanel server it should be:

    cd /home

    for a in *; do /usr/local/cpanel/bin/restoregrants --cpuser=$a --db=mysql --all; done;

    ReplyDelete