Reset/Change the MySQL Root Password on a cPanel Server (Linux)

On a Linux server or VPS with cPanel/WHM, there are two ways to reset the root password for MySQL. One method uses the WHM admin web panel, while the other uses the command line (shell).

Reset the MySQL root password in WHM

On servers with cPanel/WHM, it is recommended to change the MySQL root password via WHM. Follow the instructions below to change the MySQL root password in WHM:

1. Log in to the WHM admin interface at: https://cpanel.yourserver.com:2087 (Using your server’s hostname or IP address.)

Screen Shot 2015-12-16 at 10.15.54 PM

2. Look in SQL Services > MySQL Root Password.

Screen Shot 2015-12-16 at 10.15.25 PM

3. Choose a secure password and commit the change. That’s all you need to do!

Screen Shot 2015-12-16 at 10.16.19 PM

Reset the MySQL root password via SSH

To change or reset your server’s MySQL root password via SSH command line, follow the steps below:

1. Connect to your server via SSH as the root user.

2. Stop the mysqld service by running the command:

/etc/init.d/mysql stop

3. Run the following commands as shown:

mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD('yourpasswordhere') where User='root';
mysql> flush privileges; 
mysql> quit

 

logo

Lightning-fast VPS hosting with enterprise SSD storage, global data centers, and 99.99% uptime. Built for developers, trusted by enterprises.

Get Help

support@solvps.com

1-888-256-8213

Live Chat Now

© 2025 Hostway Services, Inc. dba SolVPS. All trademarks, service marks, product names, and logos appearing on this website are the property of their respective owners.