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.)
2. Look in SQL Services > MySQL Root Password.
3. Choose a secure password and commit the change. That’s all you need to do!
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