If you are getting Mysql connection error in cPanel / WHM server then you have to edit your Mysql configuration file to change host name to local host IP.
#2002 Cannot log in to the MySQL server
Some how mysql login details are working fine still connection to phpadmin failed. Please try editing following file:
And change following code in it:
$cfg[‘Servers’][$i][‘host’] = ‘localhost’;
$cfg[‘Servers’][$i][‘host’] = ‘127.0.0.1’;