If you are facing mysql error on all cpanel/WHM pages

ERROR :

DBI connect(mysql:localhost,root,...) failed: Access denied for user: root@localhost (Using password: YES) at /usr/local/cpanel/Cpanel/Mysql.pm line 42 ERROR 1045: Access denied for user: root@localhost (Using password: YES) 0 / unlimited

Solution :

1. Edit the file /root/.my.cnf
pico /root/.my.cnf
2. Use the mysql root password in the file and reset the mysql password to that password in .my.cnf file.

/etc/init.d/mysqld stop
safe_mysqld --skip-grant-tables
mysql
USE mysql
UPDATE user
SET password=password("Password in .my.cnf file")
WHERE user="root";
flush privileges;
exit;
killall mysqld
/etc/init.d/mysql start