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.
I've followed instructions on numerous stackoverflow links to no avail. See below status of everything.
Below is executed on the GCE via ssh browser window.
lunchbusters_za@lamp-inst:~$ cat /etc/mysql/mysql.conf.d/mysqld.cnf | grep bind
bind-address = 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
Status: inactive
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
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)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Now I want to use workbench which is running on my Macbook to connect to the GCE:
I take the external IP from the Google Cloud Platform dashboard for my VM and try to connect using workbench.
I'm not on a private network that could block anything, I'm connected to my private wifi modem.
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.
答案 0 :(得分:2)
您可以使用SSH隧道进行连接:
gcloud compute ssh --zone us-west1-a INSTANCE_NAME -- -N -p 3306 -D localhost:3306
但是让我尝试在没有解决办法的情况下为您提供帮助。
所以我们需要遵循以下步骤:
步骤1 -检查防火墙规则-在 https://console.cloud.google.com/networking/firewalls/检查您是否有 tcp:3306 规则或包含 3306 的 tcp 范围。
步骤2 -使用端口3306 检查本地连接-在运行mysql的同一gce实例中,使用 telnet测试连接端口3306 (telnet ip-machine 3306
)。
步骤3 -检查与mysql的本地连接-在运行mysql的同一实例中,在mysql中进行连接。
步骤4 -GCP网络内部的连通性-从同一GCP项目中的另一个GCE实例执行前面的步骤。
步骤5 -GCP外部的连接端口3306-在计算机上执行步骤2 。