Bug #61713 Mysql will not bind to "localhost" if localhost is both IPv4/IPv6 enabled
Submitted: 30 Jun 2011 21:53 Modified: 26 Apr 2012 19:08
Reporter: Quanah Gibson-Mount Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Options Severity:S1 (Critical)
Version:5.5.13, 5.5.15 OS:Any
Assigned to: CPU Architecture:Any

[30 Jun 2011 21:53] Quanah Gibson-Mount
Description:
If you set mysql to bind to localhost via:

bind-address   = localhost

And you have a system with both IPv4 and IPv6 enabled, such as:

zimbra@zre-ldap002:~/conf$ cat /etc/hosts
127.0.0.1       localhost
# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback

mysql will refuse to start, claiming that "localhost" refers to more than one entry.  This makes mysql impossible to use in an IPv4 -> IPv6 transition state.  I imagine this occurs for any hostname that is both IPv4 and IPv6 enabled as well, which is going to seriously hurt peoples migration plans.

How to repeat:
See above.

Suggested fix:
Allow mysql to listen to multiple interfaces returned for a given hostname.
[2 Jul 2011 8:04] MELERIX ...
Seems we have more or less the same issue: http://bugs.mysql.com/bug.php?id=61725
[2 Jul 2011 19:17] Quanah Gibson-Mount
I would note this is new with 5.5.  This worked fine with 5.1.
[3 Jul 2011 17:35] Valeriy Kravchuk
What operating system do you use? Please, send also the results of:

ping localhost
[5 Jul 2011 17:42] Quanah Gibson-Mount
The operating system is Linux 2.6 kernel.

zimbra@zre-ldap002:~$ ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.014 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.009 ms
[16 Jul 2011 15:47] Valeriy Kravchuk
This is easy to verify:

110716 18:40:03 mysqld_safe Starting mysqld daemon with databases from /Users/openxs/dbs/5.5/data
110716 18:40:03 [ERROR] Can't start server: bind-address refers to multiple interfaces!
110716 18:40:03 [ERROR] Aborting

on the following machine:

macbook-pro:5.1 openxs$ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost 
fe80::1%lo0	localhost

I am not sure can we call this a bug formally, but some more robust behavior (like 5.1 did, just bind to IPV4, or first listed, interface) is needed.
[6 Aug 2011 23:39] Nathan Rennie-Waldock
This is very simple to verify. It's not a config or OS issue, it's a MySQL bug. It used to work in 5.1.

administrator:~$ mysqld --no-defaults --bind-address=localhost
110807  0:33:47 [ERROR] Can't start server: bind-address refers to multiple interfaces!
110807  0:33:47 [ERROR] Aborting

administrator:~$ grep localhost /etc/hosts
127.0.0.1	localhost
::1     localhost ip6-localhost ip6-loopback
administrator:~$ mysqld -V
mysqld  Ver 5.5.15-1~ppa1~natty for debian-linux-gnu on i686 (Ubuntu)
[24 Feb 2012 10:28] Georgi Kodinov
Bug #61725 and 61163 were marked as a duplicate of this one.
[5 Apr 2012 16:39] Paul DuBois
Noted in 5.5.24, 5.6.6 changelogs.

If the --bind-address option is given a host name value and the host
@ name resolved to more than one IP address, the server failed to
start. For example, with --bind-address=localhost, if localhost
resolved to both 127.0.0.1 and ::1, startup failed. Now the server
prefers the IPv4 address in such cases.
[16 Apr 2012 22:58] Quanah Gibson-Mount
This is backwards from every other open source package I deal with.  If both ipv4 and ipv6 exist, it should bind to the IPv6 localhost addr.
[21 Apr 2012 1:09] Vladislav Vaintroub
Yes, this is wrong fix. binding to IPv6 address (provided support for dual stack) is the way to go. Without dual stack, you can do whatever you want. But with dual stack,as supported by most OSes now, you'll get a socket that listens on both IPv4 and IPv6 traffic, and this is whatever you want. That patch effectively kills IPv6 support introduced in 5.5.
[21 Apr 2012 8:29] MELERIX ...
@Vladislav Vaintroub

It will make more troubles, because Windows XP doesn't support Dual-Stack, only Vista and above (http://msdn.microsoft.com/en-us/library/windows/desktop/bb513665%28v=vs.85%29.aspx).
[21 Apr 2012 20:11] Vladislav Vaintroub
I do not care much aboout Windows XP,where support for IPv6 is experimental and not switched on by default. As I already said, in general case, MySQL could do whatever they want to on systems without dual stack support. On systems with dual stack forcing IPv4 by default does not make sense.
[21 Apr 2012 21:22] MELERIX ...
only in XP SP1 is experimental.

XP SP2/SP3 contain "Advanced Networking Pack" (http://www.windowsnetworking.com/articles_tutorials/ipv6-support-microsoft-windows.html) so is not experimental anymore.

anyway you should always care about XP machines, because XP is still the more used OS (in most of the enterprises and services) than Vista or W7.
[22 Apr 2012 1:49] Quanah Gibson-Mount
And *NIX oses are used more than either of those for things like mysql.  If Winblows XP needs to be special cased, then that should be detected and handled by configure at build time.  Every other modern OS on the planet shouldn't suffer for MS's idiocy.
[26 Apr 2012 19:03] Sveta Smirnova
Quanah,

please open separate report saying this bug was fixed in not proper way.
[26 Apr 2012 19:08] Quanah Gibson-Mount
I've filed http://bugs.mysql.com/bug.php?id=65122