Reputation: 53
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.
Upvotes: 1
Views: 1702
Reputation: 1301
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.
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
).
Step 3 - Check local connectivity with mysql - From the same instance that you have mysql running connect in mysql.
Step 4 - Connectivity inside the GCP network - Execute the previous steps from another GCE Instance in the same GCP project.
Step 5 - Connectivity port 3306 outside GCP - Execute the step 2 from your machine.
Upvotes: 4