使用 IP 连接到云 SQL

Connect to Cloud SQL using IP

我想使用 IP 连接到 Google 云 SQL 实例(而不是来自其他 google 服务,如 appengine)。要连接,我正在使用 phpMyAdmin 和 MySql,两者都无法连接。

CloudSql 实例详细信息

连接客户端规范

所以我有一个可以从任何地方连接但仍然无法连接的实例。

MySql 使用 ssh

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

然后出现错误

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';

这里的错误是:#2003 - Can't connect to MySQL server on 'the:ipv6:of:the:instance' (110) — The server is not responding.

正在验证 ipv6

由于我使用 ipv6 进行连接,因此我必须确认我没有产生幻觉并且我确实是从 ipv6 客户端进行连接。

phpMyAdmin 是 http://[my:own:ipv6:address]/index.php 的 运行 所以毫无疑问我确实在使用 ipv6

[edit] 根据 的建议,我从客户端 运行 ping6 www.google.com 进行了工作,还检查了客户端是否可以通过从另一台计算机对其执行 ping 操作,使用其 ipv6 进行访问(来自 windows:ping -6 my:own:ipv6:address

参考资料

其他我试过的东西

任何 帮助连接或至少调试正在发生的事情将不胜感激。我想澄清一下,我不认为自己在网络相关的东西上比新手高。

鉴于两个不同的案例有不同的错误,它们显然是不同的问题。

命令行问题

您通过 SSH 连接到的主机上可能没有 IPv6 连接 - 例如 GCE 没有。要对此进行测试,请尝试 运行 ping6 www.google.com。您可能还在端口 3306 上设置了出站防火墙。

PHPMyAdmin 问题

您应该使用 $cfg['Servers'][$i]['host'] 而不是 $cfg['Servers'][$i]['socket']。您还需要设置密码,可能还需要设置用户名。你不应该 运行 Cloud SQL 不需要密码。