Logins in MySQL can be a little strange to understand.
When identifying a login, MySQL first searches by host then by username. However, the searches are not exact and wildcards can be included. Consider the following:
Host Username Password
xtest1 tester abc
xtest2 tester xyz
If the user tester attempts to login from xtest1 it must provide the password abc, however, logging in from xtest2 the password xyz must be used.
With wildcards this becomes even more complicated (wildcards are always placed at the end when sorting hosts):
Host Username Password
xtest1 tester abc
% tester xyz
In this case here from xtest1 the password to be used is abc but any other host the password xyz must be used.
There are also special host names (localhost) which represents an internal connection via a socket. So if you have:
Host Username Password
localhost tester abc
If you attempt to login using the -h option and the hostname (or IP address) this will not find an entry in the users table and hence will fail the login. If on the other hand you do not supply a hostname (if you are logging in from the same machine) then it will use localhost and perform the login with the password abc.
Ronan Cashell
Senior Oracle/MySQL Administrator
IT Integrated Business Solutions
http://www.it-iss.com