BuycPanel Blog

BuycPanel Blog

Latest news and updates

Steps to Restore Database Grants in cPanel

Posted by Allura on 20 08 2019.

Introduction
With the help of restoregrants utility, a database user can restore the database grants in case the user loses its access to databases.Use the Restoregrants Utility to Restore the User’s Database Access
One can run either of the following commands from the command line 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 
Variables with Description$cpuser: The cPanel username which has lost its access to databases.
{mysql, pg}: The type of database: mysql for MySQLR or pg for PostgreSQLR.
$dbuser: The database user allowing one to restore. If one uses the –dbuser flag, the $dbuser variable will be consisting the database user’s name, whereas, if one use the –all flag, the script will be restoring grants for all the database users which cPanel account holds.Update the cPanel User’s Password to Restore Database Access
In case the restoregrants script fails…

Introduction

With the help of restoregrants utility, a database user can restore the database grants in case the user loses its access to databases.

Use the Restoregrants Utility to Restore the User’s Database Access

One can run either of the following commands from the command line 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

 

Variables with Description

  1. $cpuser: The cPanel username which has lost its access to databases.
  2. {mysql, pg}: The type of database: mysql for MySQLR or pg for PostgreSQLR.
  3. $dbuser: The database user allowing one to restore. If one uses the –dbuser flag, the $dbuser variable will be consisting the database user’s name, whereas, if one use the –all flag, the script will be restoring grants for all the database users which cPanel account holds.

Update the cPanel User’s Password to Restore Database Access

In case the restoregrants script fails to restore database access, then the owner or holder of the account, that is, either the cPanel user or WHM user can reset the cPanel account password to restore grants.

  • The cPanel users can navigate to cPanel’s Password & Security interface (cPanel >> Home >> Preferences >> Password & Security) to reset their account passwords.
  • WHM users can navigate to cPanel’s List Accounts interface (WHM >> Home >> Account Information >> List Accounts) to reset their password.

Conclusion

All information about the feature helping in technically restoring the database information and reset the passwords as and when required is outlined in this review.