Bug #11822 Reverse lookup for 127.0.0.1 not accounted for in mysql_install_db
Submitted: 8 Jul 2005 17:13 Modified: 5 Aug 2005 22:52
Reporter: Matthew Lord Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:all OS:*nix
Assigned to: Jim Winstead CPU Architecture:Any

[8 Jul 2005 17:13] Matthew Lord
Description:
mysqld uses reverse DNS lookups for TCP/IP connections.  Red Hat, Slackware and *BSD among others use localhost.localdomain or localhost.$REAL-DOMAIN for the 127.0.0.1 entry in /etc/hosts and other applications rely on it (gnome for example will complain).

mysql_install_db uses a static "localhost" value for the default root and anonymous accounts.
This means that if you connect over tcp/ip and you have localhost.localdomain in your hosts file you will not be albe to connect.

This is most commonly experienced by people using connector/j on such platforms because Java has no sockets and all connections are over tcp/ip.

You can look at any of our Red Hat or Fedora machines and see the localhost entry:
127.0.0.1               localhost.localdomain localhost

How to repeat:
edit /etc/hosts and use this as your 127.0.0.1 entry:
127.0.0.1       localhost.localdomain   localhost

mysql -h 127.0.0.1 -u root -p 

Suggested fix:
mysql_install_db should also use a reverse DNS lookup for 127.0.0.1 rather than using the static "localhost" value for the default accounts.
[11 Jul 2005 22:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/26918
[18 Jul 2005 23:58] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/27274
[20 Jul 2005 0:57] Jim Winstead
Fixed in 5.0.10. 127.0.0.1 is now always resolved to 'localhost'.
[20 Jul 2005 15:15] Mike Hillyer
Documented in 5.0.10 changelog.
[25 Jul 2005 19:06] Matthew Lord
Patch didn't fix the problem.

To repeat the problem with the current patch
use a recent 5.0.10 bk build and these steps:

edit /etc/hosts and use this as your localhost line:
127.0.0.1       localhost.localdomain   localhost

start mysqld

mysql -h 127.0.0.1

If you started mysqld without a localhost extension
in /etc/hosts you can see the problem by issuing
flush hosts; after making the change and then connecting
with mysqlc as above.
[25 Jul 2005 19:07] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/27562
[27 Jul 2005 11:02] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/27633
[27 Jul 2005 16:41] Jim Winstead
Fixed in 5.0.10b for Windows, and 5.0.11 for all other platforms.
[1 Aug 2005 3:59] James Day
With 5.0.10 incorporating this change:

>type c:\windows\hosts
127.0.0.1       localhost

>ipconfig /flushdns

Windows IP Configuration

Successfully flushed the DNS Resolver Cache.

>ipconfig/displaydns

Windows IP Configuration

         1.0.0.127.in-addr.arpa
         ----------------------------------------
         Record Name . . . . . : 1.0.0.127.in-addr.arpa.
         Record Type . . . . . : 12
         Time To Live  . . . . : 475595
         Data Length . . . . . : 4
         Section . . . . . . . : Answer
         PTR Record  . . . . . : CookieCop

         cookiecop
         ----------------------------------------
         Record Name . . . . . : CookieCop
         Record Type . . . . . : 1
         Time To Live  . . . . : 475595
         Data Length . . . . . : 4
         Section . . . . . . . : Answer
         A (Host) Record . . . : 127.0.0.1

>mysqld --defaults-file=D:\my.ini --port=4250

>mysql --port=4250 -uroot
ERROR 1130 (HY000): Host 'CookieCop' is not allowed to connect to this MySQL server

>mysqladmin --port=4250 -uroot     shutdown
mysqladmin: connect to server at 'localhost' failed
error: 'Host 'CookieCop' is not allowed to connect to this MySQL server'

5.0.6 connects and shuts down happily. The CookieCop stuff is presumably detrius left behind from my old Windows ME version prior to an upgrade to XP, no idea how to remove it. Apparently the current Cookie Cop Plus does something similar, based on the search results I saw when trying to work out what was happening.

Perhaps trying both lookup and then fixed localhost if that fails is a good idea?
[5 Aug 2005 22:52] Mike Hillyer
Documented in 5.0.11 changelog.
[3 Sep 2005 0:07] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/29268