Connecting to the Google Cloud SQL via the MYSQL client
This article explains how to connect to cloud SQL to using the MYSQL client, which is installed on a compute engine instance.

Before you begin
You should activate two APIs in Google Cloud Console.
Menu → APIs & Services → Enabled APIs & Services
01) Compute Engine API

02) Cloud SQL Admin API

Step 01
Create a Compute Engine VM instance
Menu → Compute Engine → VM instance
- Click Create instance.
- Specify a Name for your VM. For more information
- Optional: Change the Zone for this VM.
- Select a Machine configuration for your VM.
- Optional: In the Boot disk section, click Change, Select a project and Open the image.
- In the Firewall section, Allow HTTP traffic or Allow HTTPS traffic.
7.To create and start the VM, click Create.
Step 02
Create a MySQL instance
Menu → SQL
- Click Create instance.
- Select MYSQL
- Specify an Instance ID & password.
- Select the Database version.
- To create and start the SQL instance, click Create.
Step 03
Connect MySQL instance to VM
Menu → SQL → Connections
- Click Add network.
- Specify a name
- Enter the External IP address of your VM in the Network box
- Click Done and Save buttons.
Step 04
Install & connect MySQL client on your VM
Menu → Compute Engine → VM instance
- Select your VM.
- SSH your VM.
- Run the following command in your shell
- sudo apt-get install default-mysql-server
- mysql -h INSTANCE_IP -u USERNAME -p
4. Enter the MYSQL password.
Well Done. 😀