Bug #12668 Don't cache DNS hostname lookups until there has been one successful connection
Submitted: 19 Aug 2005 7:23 Modified: 15 Jan 2011 10:04
Reporter: James Day Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:5.0.10b and later OS:Windows (Windows)
Assigned to: CPU Architecture:Any

[19 Aug 2005 7:23] James Day
Description:
As a result of the action on bug 11822, it's no longer possible to initially connect to noinstall Windows builds of MySQL if the hostname for 127.0.0.1 is not localhost (either CookieCop in the case I had, or empty, will fail because of the hostname). The problem is made harder to diagnose because the hostname cache will cache the incorrect hostname value, so just changing the hostname isn't enough, you also need to know about the hostname cache and know that you need to restart the server to flush the cache between each attempt.

Suggestion: don't cache the hostname until there has been at least one successful connection to the server. Alternatively, don't cache until at least one successful connection only when the attempt is for 127.0.0.1 and root, since that's the pair which matters just after an install.

I've only checked noinstall builds. Chances are that the installer builds are also affected.

How to repeat:
Use a noinstall Windows build 5.0.10b or later on Windows XP with localhost set to CookieCop and try to connect. Will be refused because hostname CookieCop isn't allowed to connect even though you're connecting from 127.0.01. Change the hosts file to contain "127.0.0.1 localhost", ipconfig/flushdns and try to connect again without restarting the server. Still fails because of the hostname cache. Restart the server and it'll work.

Suggested fix:
Prior to bug 11822 this wasn't an issue - the server would accept connections from 127.0.0.1 even when the hostname was not localhost. Restoring that behavior would be even more helpful.
[16 Jan 2011 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".