Is there some relevant reason why you are running the MySQL DBMS on Windows instead of Linux like with your web server?

And do you have a firewall between the DB and the Apache server?

The reason why I'm asking is that I have many times noticed that Windows does some fishy stuff in the background to try to establish credentials of the host it is connecting to/from by connecting to TCP ports 445 and 139.

So if you are dropping packets to these ports in the firewall or something like that you can get similar effects.

It could be something like this that causes what you are experiencing now.

Comment

Because whenever a windows server receives a new TCP connection it tries to authenticate the other server.
So it starts with trying to connect to the other server and in the end if the other server is not answering it continues anyway.

I read about someone that solved it by installaing Samba on the Linux server which means that the windows credential check actually gets a response.

Comment

Except that that has absolutely nothing to do to this specific problem since this was about windows checking credentials and not a DNS issue.

And even if you do want to tinker with that setting I would say that you can leave name resolve on.
Because usually you only have very few hosts (couple of web servers for example) that connect to the DB and then all these hosts will be available in the host_cache in mysql, which means that the performance impact is marginal at best. And that means that you might as well keep it.

Unless you have really screwed up your DNS settings and then I think you should fix the DNS settings instead.

Comment

I beg to differ - I experienced similar symptoms in a similar configuration as the original poster. (5-6 second delay while connecting from a Linux client to a Windows server)

In my installation, the Windows MySQL server first tried to use NetBIOS to figure out the name of the client, and it took about 5 seconds to fail. I watched this process by using Ethereal to capture the packets as the client connected to the server.

I also verified that it was a server, not a client issue by making a simple "netcat" connection to the mysql host like so:time echo "" | nc my-mysql-host 3306 >/dev/null

After setting skip-name-resolve the server no longer attempts the NetBIOS lookup. Just to double check, I commented the option out, restarted MySQL, and the problem came right back.