Bug #6348 MySQL fails to handle IPv6 hosts
Submitted: 31 Oct 2004 17:55 Modified: 2 Dec 2004 23:21
Reporter: Dan Greening
Status: Closed
Category:Server Severity:S1 (Critical)
Version: OS:Linux (SUSE 9.2)
Assigned to: Target Version:

[31 Oct 2004 17:55] Dan Greening
Description:
I ran into a commonly reported problem where Connector/J fails to connect to localhost. 
Many people seem to resolve this problem by referring to 127.0.0.1 instead.

I solved it a different way.  My /etc/hosts file contained this:

    127.0.0.1       localhost
    # special IPv6 addresses
    ::1             localhost ipv6-localhost ipv6-loopback

When I removed the reference to "localhost" under "::1" the connection succeeded.

I believe this may be a bug in Connector/J or mysqld actually, where something may fail to
correctly handle IPv6 addresses.  If you try running "mysql -h ::1", that also fails for
me (yes, I am running IPv6. SUSE 9.2 seems to turn it on by default).

How to repeat:
I think the error is in both the Java libraries and the C libraries.  Try this:

Type 

mysql -h ::1

on any system that has IPv6 enabled (SUSE 9.2 has it by default).  it will fail.

-------

Or install SUSE 9.2.  Try to make a connection through Connector/J to a database on
localhost (might check to see that /etc/hosts looks like how I described in Description
above).  It will fail.

Suggested fix:
Fix Connector/J and libmysql to correctly recognize IPv6 addresses.
[31 Oct 2004 18:27] Mark Matthews
Connector/J will handle connecting to IPv6 addresses, as long as they're not specified in
numeric form (as this clashes with the port specification, which also uses a ':'), _and_
you're using a JDK that supports IPv6 (like JDK-1.4).

However, the server (and the native clients) don't yet support IPv6, so you can't connect
to them, even though the JDBC driver has figured out an address that it can pass to the
JDK socket libraries.

Ipv6 support is on the server roadmap, but isn't yet slated for a particular version.
[1 Nov 2004 1:29] Dan Greening
Just FYI, although you can claim that MySQL not handling IPv6 is a "feature request", it
will be viewed as a bug to those who cannot run it on SUSE 9.2.

You should add documentation specifically addressing this issue, somewhere.  Then you can
take your time fixing the problem.
[2 Dec 2004 23:21] Mark Matthews
Fixed for 3.0.17 and 3.1.5...The driver will now loop through all possible IP addresses
for a given host, accepting the first one that works.