MySQL is the primary database software for sites hosted on cPanel-managed servers, including WordPress® and ecommerce applications such as Magento. Because MySQL has to manage read and write permissions for many different sites and databases, it is a multi-user system. 

Each user account has a set of permissions that limit its access. The MySQL root user has no limits; as the database server’s administrator, the root user can create and delete accounts and modify any other account or database. 

If the MySQL root user’s password is exposed to third parties or non-admin server users, it should be changed. A bad actor who gets hold of the password may abuse it to disrupt sites and access sensitive information. 

In this article, we explain how to change the MySQL root password with cPanel & WHM. We’ll also explore changing other MySQL user account passwords and show you a shortcut for quickly changing WordPress database passwords in WP Toolkit

Reset the MySQL Root Password with cPanel & WHM

Before we get to changing passwords, let’s clear up a common misunderstanding: The MySQL root user is not the server’s root user. Your server’s Linux operating system has multiple users and a root account, and so does the MySQL database software. But Linux and MySQL users are unconnected; different systems manage them.

This article focuses on the MySQL root account. If you want to change your cPanel server’s root account password, read the Change Root Password documentation instead. 

To change the MySQL root password, open WHM and navigate to MySQL Root Password under SQL Services in the sidebar menu. 

Enter a new password in the Password and Password[again] fields. The password should be long, complex, and hard to guess. A weak password may be compromised in a brute force or dictionary attack, creating a critical security vulnerability.  

The page includes a password strength test, and you should choose a password it considers Very Strong. We also integrate a Password Generator programmed with default options to create a secure and hard-to-guess password.

If you expect to connect remotely to the MySQL server with the root account, take note of the password. It will not be displayed again. However, you can retrieve the MySQL root password from a file stored on your server.  Log in with SSH as the root user and run the following command:

cat /root/.my.cnf

This displays a file that includes the MySQL root password. You should not edit this file; doing so won’t change the password, but it will prevent cPanel from accessing the root account and managing the MySQL server. 

We strongly advise that you change the MySQL root password in WHM and not by interacting with the MySQL service directly. While it is possible to change the root password from the command line, you would also need to configure other parts of the system to use the new password. When you use WHM, it takes care of that configuration for you. 

Reset MySQL User Account Passwords 

Changing the password for other MySQL users is also straightforward. The server administrator can edit any MySQL user’s account in WHM. cPanel users can edit passwords for databases their account manages. 

Changing MySQL User Account Passwords in WHM

Open WHM and select Change MySQL User Password under SQL Services in the sidebar menu. 

Choose the MySQL user you’d like to edit from the dropdown menu. Enter and confirm the new password. As with the root password interface, Change MySQL User Password includes a password strength meter and a password generator. 

Changing MySQL User Account Passwords in cPanel

Log in to your cPanel account and select MySQL Remote Databases from the Databases section of the main page menu. 

This tool adds new MySQL users and modifies databases, but we’re interested in the Current Users section at the bottom of the page. Here you will see a list of database users and, in the Actions column, a Change Password option.

The interface here is similar to cPanel’s other password editing tools, with the familiar strength indicator and password generator. 

Changing WordPress MySQL Database Passwords in cPanel

If you look at the images in the last section, you’ll see that many database users have a “wp” prefix. These are users cPanel created for WordPress-specific databases. WordPress hosts are often asked to change MySQL passwords when hosting clients lose them. 

You can change WordPress user database passwords as we described in the previous section. But if you do it that way, you also have to reconfigure WordPress to use the new password. There is a quick and easy way to accomplish both tasks simultaneously in the cPanel WP Toolkit (WTK). 

  1. Open WTK and find the site you want to edit. 
  2. Expand the detail view and select the Database tab. 
  3. Click the Change link next to Database user name. 

In the pop-up that appears, you can edit both the database username and password. WTK configures the database and the site, making WordPress database password edits a simple one-step process. 

Streamlined MySQL Database Management with cPanel & WHM

We’ve focused on just one aspect of MySQL management in this article, but cPanel & WHM is a complete database management solution. It includes easy-to-use interfaces that automate the most common tasks and powerful database editing tools like phpMyAdmin for manipulating any aspect of your server’s databases. As always, if you have any feedback or comments, please let us know. We are here to help in the best ways we can. You’ll find us on Discord, the cPanel forums, and Reddit. Be sure to also follow us on FacebookInstagram, and Twitter.