I was able to recreate your same symptoms on my test box, hopefully this will help.
In MySQL, users are defined by two parts (name and host). By default, MySQL will have 3 root users:
mysql> SELECT host,user,password FROM mysql.user WHERE user='root'; +-----------------------+------+-------------------------------------------+ | host | user | password | +-----------------------+------+-------------------------------------------+ | localhost | root | | | localhost.localdomain | root | | | 127.0.0.1 | root | *PASSWORD_HASH_GOES_HERE | +-----------------------+------+-------------------------------------------+
The password field will either be blank (no password) or have a hash stored. If you set the password for one specific user, it doesn't automatically update all, since MySQL sees them as different users.
For example:
mysql> set password for 'root'@'127.0.0.1' = password('Password');
will update the password for 'root'@'127.0.0.1', but not 'root'@'localhost' or 'root'@'localhost.localdomain'
Take a look at the skip_name_resolve variable:
mysql> show variables like 'skip_name_resolve'; +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | skip_name_resolve | ON | +-------------------+-------+ 1 row in set (0.00 sec)
By Default skip_name_resolve is OFF, and will attempt to resolve all IP Addresses to hostnames. For example, if you connect as 'root'@'127.0.0.1', MySQL will change connect you as 'root'@'localhost'.
If it is ON, MySQL will see and connect 'root'@'127.0.0.1' and 'root'@'localhost' as seperate users. And they may or may not have different passwords, depending on how they were set.
So first, I would check to see any password differences: mysql> SELECT host,user,password FROM mysql.user WHERE user='root';
If there are, you can fix them, or you can continue investigating.
Then I would check skip_name_resolve: mysql> show variables like 'skip_name_resolve';
If it is ON, I would find out where it's being set (for example /etc/my.cnf) and remove it, unless there is a need for it.
Hopefully this helps you out!
ping localhostand see what it says.