BuycPanel Blog

BuycPanel Blog

Latest news and updates

What are the Steps to Restore Database Grants?

Posted by Allura on 12 11 2019.

Introduction
It may happen that a user may not be able to access the databases. Using the restore grants utility, you can allow grants to a user to access databases if he loses the access grant.Uses of Restore Grants Utility
Using any of the following commands given in the command line below, you can allow a user his/her grants to access a database. Execute the following commands to achieve your objective./usr/local/cpanel/bin/restoregrants –cpuser=$cpuser –db={mysql, pg} –dbuser=$dbuser
/usr/local/cpanel/bin/restoregrants –cpuser=$cpuser –db={mysql, pg} –allThe descriptions of the variables are given below in a list. Read to follow through.$cpuser: This denotes the username of the cPanel user who has lost access to a database or databases.
{mysql, pg}: This denotes the database type. Specifically, mysql stands for MySQL® or pg for PostgreSQL®.
$dbuser: The user of the database whose grants you want to restore. The –dbuser flag uses the $dbuser variable, which comprises the database…

Introduction

It may happen that a user may not be able to access the databases. Using the restore grants utility, you can allow grants to a user to access databases if he loses the access grant.

Uses of Restore Grants Utility

Using any of the following commands given in the command line below, you can allow a user his/her grants to access a database. Execute the following commands to achieve your objective.

  1. /usr/local/cpanel/bin/restoregrants –cpuser=$cpuser –db={mysql, pg} –dbuser=$dbuser
  2. /usr/local/cpanel/bin/restoregrants –cpuser=$cpuser –db={mysql, pg} –all

The descriptions of the variables are given below in a list. Read to follow through.

  1. $cpuser: This denotes the username of the cPanel user who has lost access to a database or databases.
  2. {mysql, pg}: This denotes the database type. Specifically, mysql stands for MySQL® or pg for PostgreSQL®.
  3. $dbuser: The user of the database whose grants you want to restore. The –dbuser flag uses the $dbuser variable, which comprises the database user’s name. If you wish to make use of the –all flag, the script understands that access to all other database users owned by the cPanel account needs to be granted and it works accordingly to do so.

Procedure to Update the cPanel User’ s Password to Restore Database Access

The users who lose access to the databases on a cPanel account can retrieve the access by the restore grants utility as the system works to restore the access following certain commands for this purpose. However, under specific circumstances, the system might fail to follow through and restore the grants successfully. In this case, the user of the cPanel or user of the WHM can opt for an alternative method by changing the password of the account.

The password of the cPanel account can be reset by the user to restore grants to people who need it.

  1. Users of cPanel can reset or change the password of the account in cPanel’s Password & Security

This can be found at the path given by (cPanel >> Home >> Preferences >> Password &Security).

  1. Users of WHM can change or reset their password in List Accounts of the WHM interface.

This can be found at the given path (WHM >> Home >> Account Information >> List Accounts).

Conclusion

This document puts down methods in which database grants can be restored using restore grants utility. Find alternative ways to restore grant rights if the system fails to cooperate in this document as well.