Our PHP development team encountered many situations where remote connections to mysql take 5 seconds to return responses.  In some cases, we’ve rebuilt servers after tearing our hair out.  This has happened on Windows, Linux, PHP, apache, WordPress, joomla, Zabbix, and so many cases it makes me want to scream.  Of course, people love to point to Windows as the problem.  Lots of other people say optimize mysql.  Others say to configure your long_query_time parameter and check the logs.  None of this matters, because it isn’t Windows, it isn’t Linux, it isn’t PHP, it isn’t apache, it isn’t WordPress, it isn’t Zabbix, and it isn’t an optimization issue.

It is a reverse DNS problem.  Not a DNS problem, a reverse DNS problem.  A reverse DNS problem on your mysql server.  Which is absurd.  Why on earth would mysql server check for reverse DNS?  Why?

Because mysql wants to look at the host name for GRANT lookups.  Jeez.  Who cares.  I’d rather just fail the security than have all my applications wait five or ten seconds for every operation.


You can do one of two things to fix this:

1. Work with your network administrator to create reverse DNS PTR records.  Maybe you can get this done, maybe you can’t.

1b.  Create a host entry in the hosts (/etc/hosts or c:\windows\system32\drivers\etc\hosts).  This is good for both forward and reverse DNS.  Just never forget that you made it three years from now when you rename servers.

2.  Configure mysql with skip-name-resolve as described here.  For people that can’t control their reverse DNS PTR records – or can’t get help having them configured – this is the best option.

Want to make this really crazy?  If you have a multiple subnet network work with multiple DNS servers for hundreds of domains and split-horizon DNS for internal networks, you may have the extra fun of configuring conditional forwards for reverse DNS.  If you want to know how to do that, just ask in the comments.  (It’s not hard, so google may have already helped you.  You just have to know you need it.)

My apologies that this is an unusually snarky post.  It’s only consumed 80+ hours cumulative of my life.


MySQL, PHP Development