BuycPanel Blog

BuycPanel Blog

Latest news and updates

Steps to Restore Database Grants in cPanel

Posted by Allura on 30 10 2018.

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

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 cPanel User’s Password In Restoring Database Access
In case the restore grants script fails to restore database access,…

Introduction

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

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 cPanel User’s Password In Restoring Database Access

In case the restore grants 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

This feature helps in technically restoring the database information and reset the passwords as and when required.