首页 文章

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

提问于
浏览
0

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

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

当使用ssh连接到VPS A时,我可以使用命令行连接到谷歌 Cloud 实例,因此原则上连接似乎是可能的,但我的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

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

相关问题