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

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

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

配备 Ubuntu 16.04、phpmyadmin 和 mariadb 的 VPS A Google Cloud SQL 实例

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

但是与本地主机 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)

最佳答案

Stackoverflow 中也有类似的旧案例,所有解决方案都指向用户权限未定义。在我看来,理解这个问题最有用的帖子是 this one 。考虑到您正在使用 PHPMyAdmin,还可以查看 this drupal question .

关于php - 如何从外部 PHPMyAdmin 安装连接到 Google 云 SQL 实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49718248/

相关文章:

php - 如何使用网站中 phpmyAdmin 中保存的 URL 显示多个图像?

mysql - 提交字符串中包含分号的数据库值?

java - Java 中的传统加密和 PHP 中的解密

php - 如何在 Laravel 中合并来自 Eloquent 模型的两个查询的结果?

MySQL UNION 似乎无法正常工作

php - 第一次尝试连接mysql服务器得到错误信息: "mysql: command not found"

php - 无法访问 phpmyadmin 连接数据库

php - 如何使用导出选项在数据表中显示 100k 条记录?

php - ImageMagick SVG 到 PNG 转换删除渐变

javascript - jQuery:当两个表都有同名的行时,如何使用循环解析来自 2 个表的数据的表?