将mysql工作台连接到GCE mysql [英] Connect mysql workbench to GCE mysql

查看:119
本文介绍了将mysql工作台连接到GCE mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经两天了,我已经放弃了.我无法使用工作台连接到运行mysql的Google计算引擎.

It's been two days and I've given up on this. I'm unable to connect to my google compute engine running mysql using workbench.

我遵循了许多stackoverflow链接上的说明,但无济于事.请参阅下面的所有状态.

I've followed instructions on numerous stackoverflow links to no avail. See below status of everything.

以下是通过ssh浏览器窗口在GCE上执行的.

Below is executed on the GCE via ssh browser window.

lunchbusters_za@lamp-inst:~$ cat /etc/mysql/mysql.conf.d/mysqld.cnf | grep bind

绑定地址= 0.0.0.0

请注意,我也在绑定地址上方注释掉了.

Note I've also commented out above bind-address.

lunchbusters_za@lamp-inst:~$ netstat -an | grep 3306

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN

lunchbusters_za@lamp-inst:~$ sudo ufw status

状态:无效

防火墙甚至没有启用,但无论如何我都允许3306/tcp.

Firewall not even enabled, but I have allowed 3306/tcp anyway.

下面是我正在使用的用户,它可以连接.我将密码设置为否"只是为了排除这种情况.

Below is the user I'm using, it can connect. I've set password to NO just to rule that out.

lunchbusters_za@lamp-inst:~$ mysql -u admin

欢迎使用MySQL监视器.命令以;结尾;或\ g. 您的MySQL连接ID为11 服务器版本:5.7.25-0ubuntu0.18.10.2(Ubuntu)

Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 5.7.25-0ubuntu0.18.10.2 (Ubuntu)

版权(c)2000、2019,Oracle和/或其分支机构.保留所有权利.

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle是Oracle Corporation和/或其Oracle的注册商标. 会员.其他名称可能是其各自的商标 所有者.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

输入帮助;"或'\ h'寻求帮助.键入"\ c"以清除当前输入语句.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

现在,我想使用Macbook上运行的工作台连接到GCE:

我从Google Cloud Platform仪表板获取了我的VM的外部IP,并尝试使用工作台进行连接.

I take the external IP from the Google Cloud Platform dashboard for my VM and try to connect using workbench.

我不在可能阻止任何内容的专用网络上,我已连接到专用wifi调制解调器.

I'm not on a private network that could block anything, I'm connected to my private wifi modem.

我也可以从尝试连接的Macbook上ping外部IP.我也可以从本地Web浏览器访问phpmyadmin.

I can also ping the external IP from my macbook I'm trying to connect from. I can also access phpmyadmin from my local webbrowser.

推荐答案

您可以使用SSH隧道进行连接:

You could use SSH tunnel to connect:

gcloud compute ssh --zone us-west1-a INSTANCE_NAME -- -N -p 3306 -D localhost:3306

但是让我尝试在没有解决办法的情况下为您提供帮助.

But let me try help you without a workaround.

所以我们需要遵循以下步骤:

So we need to follow these steps:

  • Step 1 - Check the firewall rules - In https://console.cloud.google.com/networking/firewalls/ check if you have a rules for tcp:3306 or a tcp range that includes 3306.

第2步-使用端口3306 检查本地连接-在运行mysql的同一个gce实例中,使用 telnet测试连接端口3306 (telnet ip-machine 3306).

Step 2 - Check local connectivity with port 3306 - In the same gce instance that you have mysql running test the connectivity using telnet in the port 3306 (telnet ip-machine 3306).

步骤3 -检查与mysql的本地连接-在运行mysql的同一实例中,在mysql中进行连接.

Step 3 - Check local connectivity with mysql - From the same instance that you have mysql running connect in mysql.

步骤4 -GCP网络内部的连接-从同一GCP项目中的另一个GCE实例执行前面的步骤.

Step 4 - Connectivity inside the GCP network - Execute the previous steps from another GCE Instance in the same GCP project.

步骤5 -GCP外部的连接端口3306-在计算机上执行步骤2 .

Step 5 - Connectivity port 3306 outside GCP - Execute the step 2 from your machine.

这篇关于将mysql工作台连接到GCE mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆