A cPanel server has lost its MySQL root password — someone rotated it manually, the password manager entry is gone, or the server was inherited and the previous admin never wrote it down. The standard MySQL “skip-grant-tables” recovery works, but if you stop there, cPanel’s daemons stop being able to log into MySQL on their next cycle and the host degrades over the next 24 hours. The right reset updates both MySQL and cPanel’s stored credentials.
What’s happening
cPanel stores the MySQL root password in /root/.my.cnf (a standard MySQL client config). It uses this for whmapi1 operations, the MySQL/MariaDB Upgrade tool, backup invocations, and the dbmap maintenance routines. Resetting the password in MySQL without updating /root/.my.cnf leaves cPanel pointing at a stale password — the next whmapi1 list_dbs call fails, and cascading failures follow.
cPanel does have a built-in command for this: /usr/local/cpanel/bin/cpmysql-reset-password. It generates a new password, updates MySQL, and writes the new password to /root/.my.cnf atomically. Use it whenever possible. The manual procedure below is only for cases where the cPanel command itself can’t run (MySQL is broken in some way that prevents it from logging in).
How to verify
mysql -e "SELECT VERSION()" 2>&1 | head
ls -la /root/.my.cnf
cat /root/.my.cnf # contains the current password
ps aux | grep -E "mysqld|mariadbd"
systemctl status mariadb
If mysql -e returns a result without prompting for password, root authentication is currently working (you just don’t know the password) — use the cPanel command. If mysql -e prompts for password or fails to connect, you’re in the manual path.
The fix
Preferred: use the cPanel command.
/usr/local/cpanel/bin/cpmysql-reset-password
It does everything: stops MySQL, generates a strong password, restarts MySQL, updates /root/.my.cnf. Verify by running mysql -e "SELECT 1" and whmapi1 list_dbs.
Manual procedure when the cPanel command can’t run:
- Stop MySQL:
systemctl stop mariadb. - Start MySQL with grant tables disabled:
This bypasses the privilege system and lets you connect without a password.mysqld_safe --skip-grant-tables --skip-networking &--skip-networkingkeeps the daemon on the socket, no TCP — important so nobody else connects during the window. - Connect and reset:
Themysql -u root FLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY 'new-strong-password'; FLUSH PRIVILEGES;FLUSH PRIVILEGESbefore the ALTER is required when started with--skip-grant-tablesso MySQL re-reads the grant tables. - Stop the bypass instance and start normally:
killall mysqld systemctl start mariadb - Test the new password:
Enter the new password. If it works, proceed.mysql -u root -p - Update
/root/.my.cnf:/root/.my.cnf: [client] user=root password=new-strong-passwordchmod 600 /root/.my.cnfso only root can read it. Without this step, cPanel’s internal calls keep using the old password and fail. - Restart cPanel daemons so they pick up the new credential:
/scripts/restartsrv_cpsrvd - Verify cPanel still works:
whmapi1 list_dbs | head whmapi1 list_users | head /scripts/dbmap_check
For takeover scenarios where the inherited password is unknown and you don’t trust the existing state, Stack Harbor’s cPanel server administration team runs the cPanel reset command as part of the standard intake checklist and rotates credentials into a password manager so the next person doesn’t repeat the exercise.