From long time I have faced Mysql slow query from IP other than localhost it was retrieved from another PC but localhost was working well.After much toiling for the answer I found that placing “skip-name-resolve” as a line in my.cnf solved the issue. ,This worked even though no user rights in my database not assigned any names, only IP addresses.
Reason:
When a client connects to mysqld, mysqld spawns a new thread to handle the request.This thread first checks whether the host name is in the host name cache.
If not, the thread attempts to resolve the host name The thread takes the IP address and resolves it to a host name. It then takes that host name and resolves it back to the IP address and compares to make sure it is the original IP address so this thread significantly increases the query time and slows down the system.This reverse DNS is suitable for the system connected to internet for letting certain domains to except the request but for system in the local LAN has to suffer a lot time since the local IP normally does not resolve to a name.