Make sure you have installed gcloud
which you will need for setting up and connecting to your SSH tunneled MySQL database. Installation instructions for Google Cloud SDK command line tools are here. You will typically need to close your terminal and restart it to make sure all the environmental variables are set.
Check the networking of your Cloud SQL instance so that it matches the Compute Engine network.
Navigate to your list of instances then Click on the Name (ssh-bastion
in this case) > Click Edit at the top > Scroll to SSH Keys > Click Show SSH Keys to copy in the public key.
The public key is the result of running a command like cat ~/.ssh/google_cloud_rsa.pub
and comes from a key that you must create yourself on your machine.
IMPORTANT: The comment on the key must match the username of your google cloud account. So if your Gsuite or Gmail email is arctype@tutorial.com you must generate the key with ssh-keygen -C "arctype"
. If you do not do this and still upload the key, you will get permission denied.
We show how to find your Google Cloud SQL credentials in another article, but for this setup you need the Private IP Address.
In a SQL client like Arctype, you must enter several pieces of information, the Database Host
, Database User
, Database Password
, Database Name
, SSH Host
, SSH User
, and SSH Key File
. These can all be found from the steps above.
Click Test Connection to ensure everything is working and then Save to start editing your database!