App overview screenshotSQL and Database Guides
PostgresMySQL
Try our free SQL Client
Tools
Connecting to MySQL
Connecting to drivers
Installing MySQL
Setting up MySQL
MySQL   >   
Connecting to MySQL   >   
MySQL Bastion on Google Cloud

Connect to MySQL on Google Cloud with SSH

Access The gcloud Command Line Tool

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.

Ensure Google Cloud Compute Access

Check the networking of your Cloud SQL instance so that it matches the Compute Engine network.

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.

Add a SSH key to Google Cloud.

Get the Database Credentials

We show how to find your Google Cloud SQL credentials in another article, but for this setup you need the Private IP Address as your database configuration should look like the image below. In the Overview tab of this example, the private IP address is 10.53.64.4.

Private IP networking in Google Cloud.

Connect over SSH to Your Google Cloud Instance

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. A successful connection will look like this.

Successfully connect via SSH tunnel to a Google Cloud SQL instance in Arctype.

Click Test Connection to ensure everything is working and then Save to start editing your database!

Want to ask for help on databases or SQL? Join our Discord community.