• Praveenkumar Hulakund's avatar
    Bug#12762885: 61713: MYSQL WILL NOT BIND TO "LOCALHOST" IF LOCALHOST IS BOTH · aab9623a
    Praveenkumar Hulakund authored
                         IPV4/IPV6 ENABLED
    
    Analysis:
    ----------------------
    The problem was that if a hostname resolves to more than one IP-address,
    the server (5.5) does not start due to an error. In 5.1 the server used to
    take some IP-address and start.
    
    It's a regression and should be fixed.
    
    5.5 supports IPv6, while 5.1 does not. However, that should not 
    prevent the server from start -- if a hostname has both IPv4 and IPv6 addresses,
    the server should choose some IPv4-address and start.
    
    It's been decided to prefer IPv4-address to be backward compatible with 5.1.
    
    Another problem was that the 5.6 server did not report proper error message
    when the specified hostname could not be resolved. So, the code has been 
    changed to report proper error message.
    
    Testing
    ================================
    5.5
    =============================
    invalid hostname (localhos):
      => Following error message reported.
         120308 15:52:09 [ERROR] Can't start server: cannot resolve hostname!
         120308 15:52:09 [ERROR] Aborting
    
    invalid ip_address:
      => Following error message reported.
          120308 15:56:06 [Note] Server hostname (bind-address): '123.123.123.123'; port: 3306
          120308 15:56:06 [Note]   - '123.123.123.123' resolves to '123.123.123.123';
          120308 15:56:06 [Note] Server socket created on IP: '123.123.123.123'.
          120308 15:56:06 [ERROR] Can't start server: Bind on TCP/IP port: Cannot assign requested address
    
    Only ipv4 host configured:
      => Following message logged 
        120308 16:02:50 [Note] Server hostname (bind-address): 'localhost'; port: 3306
        120308 16:02:50 [Note]   - 'localhost' resolves to '127.0.0.1';
        120308 16:02:50 [Note] Server socket created on IP: '127.0.0.1'
    
    Only ipv6 host configured:    
      => Following message logged 
        120308 16:04:03 [Note] Server hostname (bind-address): 'localhost'; port: 3306
        120308 16:04:03 [Note]   - 'localhost' resolves to '::1';
        120308 16:04:03 [Note] Server socket created on IP: '::1'.
    
    ipv4 and ipv6 host configured:
      => Following message logged
        120308 16:05:02 [Note] Server hostname (bind-address): 'localhost'; port: 3306
        120308 16:05:02 [Note]   - 'localhost' resolves to '::1';
        120308 16:05:02 [Note]   - 'localhost' resolves to '127.0.0.1';
        120308 16:05:02 [Note] Server socket created on IP: '127.0.0.1'.
      => Non localhost address  
        120308 16:08:20 [Note] Server hostname (bind-address): 'mysql_addr'; port: 3306
        120308 16:08:20 [Note]   - 'mysql_addr' resolves to '10.178.58.216';
        120308 16:08:20 [Note]   - 'mysql_addr' resolves to 'fe80::120b:a9ff:fe69:59ec';
        120308 16:08:20 [Note] Server socket created on IP: '10.178.58.216'.
    
    More than one entry for ipv4 and ipv6 address:
      => Following message logged
        120308 16:06:19 [Note] Server hostname (bind-address): 'localhost'; port: 3306
        120308 16:06:19 [Note]   - 'localhost' resolves to '::1';
        120308 16:06:19 [Note]   - 'localhost' resolves to '::1';
        120308 16:06:19 [Note]   - 'localhost' resolves to '127.0.0.1';
        120308 16:06:19 [Note]   - 'localhost' resolves to '127.0.0.1';
        120308 16:06:19 [Note] Server socket created on IP: '127.0.0.1'.
    aab9623a
mysqld.cc 259 KB