Mysql – Users on same server connect to MySQL with different hosts

MySQLmysql-5.5

I am aware that when a connection is made to MySQL, MySQL does a reverse lookup on the IP address to determine the host it is coming from.

I have a very odd situation where I have a number of users connecting from the same server and some users are showing as coming from one host (lets say for example "myhost.com") and others are from a different host (lets say "myhost.co.uk")

The config of the connection in both cases is the same. The IP they connect from is the same. The server they connect to is the same. On both client and server PC the reverse lookup of the IP resolves to the same host (e.g. myhost.com). There is only one IP address on the server.

This is causing us problems with authentication because when adding new users (something which is an automated script) we add them using the server IP address as the host, and about 50% of the time, this is not working because when it does the reverse lookup it finds the wrong host name!

I am aware that you can turn off the host lookup in MySQL config, but at this stage I'm reluctant to do that and would rather find an answer to the problem.

Best Answer

Adding the IP and host name to the hosts file on the database server seems to have resolved this problem!