Hi Ray,
Something to keep in mind, the user defined to provide the tunnel does not necessarily have to be the same user defined to connect to the database.
i.e. You can connect to the database as “root” while using a different user in the SSH connection. In fact
SSH access for root is not enabled by default. I believe that is true for any of the GCE
public images.
My advice would be to test the tunnel and the general connections from the CLI. That can help you to isolate the issue. For example:
1)
SSH in the server using the browser and test the connectivity to the DB server.
mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 18
Server version: 10.2.12-MariaDB-10.2.12+maria~stretch-log
mariadb.org binary distribution
2) From your remote location, use regular SSH to test you have the right user and private key to access the server.
Supposing you have setup “myuser” that works with the private key located at “~/.ssh/google_compute_engine” . To access the server with IP X.Y.W.Z you can run:
ssh -i ~/.ssh/google_compute_engine myu...@X.Y.W.Z
Linux instance-3 4.9.0-5-amd64 #1 SMP Debian 4.9.65-3+deb9u2 (2018-01-04) x86_64
The SSH keys can be auto generated by
using gcloud, but you can also manually add or remove keys by following
this article. If this step works then you can test the tunnel
3) In one terminal window
establish the SSH tunnel ssh -i ~/.ssh/google_compute_engine -L 127.0.0.1:3306:
127.0.0.1:3306 myu...@X.Y.W.Z -N
The connection should be established and them from another terminal window you could connect to the local port by using the mysql client
mysql -u root -p -P 3306 -h 127.0.0.1
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.5.5-10.2.12-MariaDB-10.2.12+maria~stretch-log
mariadb.org binary distribution
If the previous steps work then you have a problem in the Workbench configuration. Something else to keep in mind is that you do not have a firewall or anti virus software that is locally avoiding the connections to be established.