Search code examples
mysqlphpmyadminipv6google-cloud-sql

Connect to Cloud SQL using IP


I want to connect to a Google Cloud SQL instance using IP (not from another google service like appengine). To connect I'm using phpMyAdmin and MySql, both cannot connect.

CloudSql Instance details

  • Instance type: MySQL First Generation tier: D1
  • Version: MySQL 5.5
  • Authorized network: ::/0 (everybody based on documentation)
  • Authorized user: a user with no password and allowed from any domain (%)

Connecting client specs

  • phpMyAdmin 4.6.4 (fresh install)
  • MySQL Version 5.5.52-cll

So I have an instance that can be connected from everywhere but still cannot connect.

MySql using ssh

mysql --host=the:ipv6:of:the:instance --user=theusername --password

and I get an error

ERROR 2003 (HY000): Can't connect to MySQL server on 'the:ipv6:of:the:instance' (110)

PhpMyAdmin config.inc.php

$cfg['Servers'][$i]['host'] = 'the:ipv6:of:the:instance';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['blowfish_secret'] = 'some secret';

The error here is: #2003 - Can't connect to MySQL server on 'the:ipv6:of:the:instance' (110) — The server is not responding.

Verifying ipv6

Since I'm connecting using ipv6, I had to verify that I'm not hallucinating and I am indeed connecting from an ipv6 client.

The phpMyAdmin was run from http://[my:own:ipv6:address]/index.php so no doubt that I was indeed using ipv6

[edit] As suggested by @David I ran ping6 www.google.com from the client and worked, also checked that the client can be accessed using its ipv6 by pinging it from another computer (from windows: ping -6 my:own:ipv6:address)

References

Other things I tried

  • Another user: root, a user with password
  • To another new cloud sql instance
  • Checked the console log viewer, nothing interesting
  • Veryfied that there is an AAAA for my ipv6 on the domain I am requesting from, that ip resolves and my dns works perfectly
  • I am not behind a proxy

Any help would be greatly appreciated to either connect or at least debug what is going on. I want to clarify that I don't consider myself above novice in network-related stuff.


Solution

  • Given that the two different cases have different errors, they are clearly different issues.

    Command Line issue

    You may not have IPv6 connectivity on the host you are SSHing to - for example GCE does not. To test this try running ping6 www.google.com. You may also have an outbound firewall on port 3306.

    PHPMyAdmin issue

    You should be using $cfg['Servers'][$i]['host'] instead of $cfg['Servers'][$i]['socket']. You will also need to set a password and possibly a username too. You should not be running Cloud SQL with no password required.