如何从外部PHPMyAdmin安装连接到Google云SQL实例?

时间:2018-04-08 13:16:09

标签: php mysql phpmyadmin google-cloud-platform google-cloud-sql

我正在尝试将现有的PHPMyAdmin连接到第二台服务器,这是一台带有SSL的Google Cloud SQL第二代mysql服务器。我目前的设置是:

VPS A与Ubuntu 16.04,phpmyadmin和mariadb Google Cloud SQL实例

当使用ssh连接到VPS A时,我可以使用命令行连接到谷歌云实例,因此原则上连接似乎是可能的,但我的phpmyadmin配置一定有问题:

mysql --ssl-ca=/xxx/server-ca.pem --ssl-cert=/xxx/client-cert.pem --ssl-key /xxx/client-key.pem -h xxx.xxx.xxx.xxx -u phpmyadmin -p

这是我的phpmyadmin配置(/var/lib/phpmyadmin/config.inc.php):

$i++;
$cfg['Servers'][$i]['verbose'] = 'VPS A';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['nopassword'] = true;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password';

$i++;
$cfg['Servers'][$i]['verbose'] = 'gcloud';
$cfg['Servers'][$i]['host'] = 'xxx.xxx.xxx.xxx';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'phpmyadmin';
$cfg['Servers'][$i]['password'] = 'same pw I used with the commandline';
$cfg['Servers'][$i]['ssl'] = true;
$cfg['Servers'][$i]['key'] = '/xxx/client-key.pem';
$cfg['Servers'][$i]['cert'] = '/xxx/client-cert.pem';
$cfg['Servers'][$i]['ca'] = '/xxx/server-ca.pem';
$cfg['Servers'][$i]['capath'] = NULL;
$cfg['Servers'][$i]['cipher'] = NULL;
$cfg['Servers'][$i]['extension'] = 'mysqli';

现在,当我访问我的phpmyadmin登录页面时,我可以选择gcloud作为服务器,输入我用于命令行连接的相同凭据:

#1045 - Access denied for user 'xxx'@'xxx.xxx.xxx.xxx' (using password: YES)

但是与localhost mariadb的连接工作正常。我哪里出错了?

更新: 读这个:https://docs.phpmyadmin.net/en/latest/config.html#example-google-ssl

我发现我必须添加$cfg['Servers'][$i]['ssl_verify'] = false;,但它没有帮助。

更新: 在使用PPA将phpmyadmin更新到最新版本后,我收到了另一个错误,谷歌搜索引导我:https://github.com/phpmyadmin/phpmyadmin/issues/12929

我应用了变通方法并且新错误消失了,但我仍然无法登录:

 mysqli_real_connect(): (HY000/1045): Access denied for user 'xxx'@'xxx.xxx.xxx.xxx' (using password: YES)

1 个答案:

答案 0 :(得分:0)

Stackoverflow中存在旧的类似情况,并且所有分辨率都指向用户权限取消定义。在我看来,理解问题的最有用的帖子是this one。考虑到您正在使用PHPMyAdmin,请查看this drupal question