How to Reset MySQL Root Password and Restore Database Grants in cPanel Server?

How to Reset MySQL Root Password and Restore Database Grants in cPanel Server?

Reset MySQL root Password

We can reset mysql root password via command line in Linux server. Also, we can use this method in cPanel server, but there is some problem WHM will not know the new root mysql password and database features will fail with access denied from mysql. So in cPanel server, you will want to reset the mysql root password through WHM.

Please refer the following link to how to reset MySQL root password in Linux server via command line. https://www.interserver.net/tips/kb/how-to-recover-the-mysql-root-password/

In this tutorial will help you to know how to reset MySQL root password via WHM.

1) Login to WHM as a root user.

2) From there select “SQL Services”.

How to Reset MySQL Root Password and Restore Database Grants in cPanel Server?

 

3) Then click on the button “MySQL Root Password”.

How to Reset MySQL Root Password and Restore Database Grants in cPanel Server?

 

 

4) Now enter the new password and click on “Change Password” button.

How to Reset MySQL Root Password and Restore Database Grants in cPanel Server?

 

Restore Database Grants.

The cPanel provides “restoregrants” utility to restore the user’s database access.

1) Login to the server as a root user via SSH.

2) Run either of the following commands from command line.

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

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

$cpuser is the cPanel username that has lost access to databases.

{mysql, pg} is the type of database: mysql for MySQL or pg for PostgreSQL

$dbuser >> The database user whose privileges you that wish to restore. If you use the –dbuser flag, the $dbuser variable will consist of the database user’s name. If you use the –all flag, the script will restore grants for all of the database users that the cPanel account owns.

If you need any further help please do reach our support department.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Block Bots using Robots.txt File?

How to Block Bots using Robots.txt File? The robots.txt file is a simple text file placed on...

PageSpeed on cPanel Server

PageSpeed on cPanel Server PageSpeed on cPanel Server PageSpeed (mod_pagespeed) is a module for...

How to change cPanel logout URL

How to change cPanel logout URL Do you know that it is possible to change cPanel logout URL any...

How to Change cPanel Style

How to Change cPanel Style How to Change cPanel Style cPanel is the most popular control panel...