无法从 mac 或 gscipt 建立与 gcloud 上 centos7 上的 mariadb(mysql)的远程连接

无法从 mac 或 gscipt 建立与 gcloud 上 centos7 上的 mariadb(mysql)的远程连接

新手在这里 - 问题:无法从 mac 或 gscript 建立与 centos7 上的 mariadb(mysql)的远程连接 - 设置:我有 2 台灯机:一台测试(107),另一台生产(35) 107 - centos6.5 带 mysql(digitial ocean 中的 vps) 35 - centos7 带 mariadb-server-5.5.52-1.el7.x86_64(gcloud 上的计算引擎) 两台机器上的 db、dbuser、dbpass 和端口(3306)相同

  • 问题详情:我可以使用 nc、mysqlworkbench 和 gscript 应用程序从 mac 建立到 107(测试服务器)上的 mysql 的远程和 jdbc 连接;但是当我尝试使用相同的用户/密码/数据库参数与 35(生产服务器)建立连接时,我收到以下响应:workbench:无法连接到“35.190.134.164”(60)gscript 上的 MySQL 服务器(抛出 jdbc 连接异常):无法建立数据库连接。检查连接字符串、用户名和密码。mac 上的 nc:...(发出命令 nc <35 的 ip 地址> 3306 后实际上没有任何反应

-我的尝试:1.https://mariadb.com/kb/en/library/configuring-mariadb-for-remote-client-access/ 35中的my.cnf如下所示:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd



#skip-networking
bind-address = 0.0.0.0

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
  1. 防火墙cmd 看起来像这样(对于活动和公共):

trusted (active) target: ACCEPT icmp-block-inversion: no interfaces: eth0 sources: services: http https ports: 3306/tcp protocols: masquerade: no forward-ports: sourceports: icmp-blocks: rich rules: public target: default icmp-block-inversion: no interfaces: sources: services: dhcpv6-client http https ssh ports: 3306/tcp protocols: masquerade: no forward-ports: sourceports: icmp-blocks: rich rules:

  1. dbuser 的密码不是问题,因为我在 107 和 35 上为同一个数据库创建了相同的用户和密码。该用户只有使用权限(选择、更新、删除、插入)并且在两台机器上都设置为%。

我已经研究这个问题三天了,但还是没能弄清楚。如能得到任何帮助我将不胜感激。我遗漏了什么?

谢谢。

答案1

经过 3 天的谷歌搜索,以及发布此问题 45 分钟后,我发现并意识到 gcloud 可能也有防火墙,瞧,它确实有,然后我找到了这份文档:

https://cloud.google.com/solutions/mysql-remote-access#modify_the_default_firewall_rule

我继续为 tcp:3306 创建了一个入口规则,现在我可以远程连接,并且我的 gscript 正在与我的 gcloud 的计算引擎实例对话。

这需要庆祝!!!

希望它能对某人有所帮助。

相关内容