Google Cloud Cloud SQL

Setup Cloud SQL for PostgreSQL on Google Cloud

Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we recommended.

Pinterest LinkedIn Tumblr

In this post, you are going to create a Cloud SQL for PostgreSQL in Google Cloud Platform and connect it to Compute Engine VM Instance.


  1. Your Compute Engine Instance is setup and running.
  2. For setting up Compute Engine, see the Setting up Compute Engine Instance.
  3. Domain name is pointed to your virtual machine.
  4. For setting up Cloud DNS, see the Setting up Google Cloud DNS for your domain.

Get your Professional Google Cloud Architect certificate with this easy to learn course now.

Creating a Second Generation instance

  1. Go to Storage >> Cloud SQL in GCP console.
  2. Click Create Instance.
  3. Select PostgreSQL and click next.
  4. Enter instance name (recommended to use your domain name without the .com or extension).
  5. Enter the password for the default user and copy it safe.
  6. Set the region for your PostgreSQL instance the same as you set in your Compute Engine VM Instance.
Create PostgreSQL Instance

Under Configuration options update the following

  1. Click set Connectivity, and under Authorized Networks click Add Networks.
  2. Enter the name in the Name field (this is optional).
  3. Enter your Compute Engine Instance IP address in the Network field.
  4. Click Done.

This setting will authorize your Compute Engine VM Instance to connect to this Cloud SQL Instance.

Connect VM Instance to Cloud SQL

Click Configure machine type and storage and choose Micro Instance

Choose SSD in Storage type

Leave everything to default and click create.

It will take some time to create a new Cloud SQL instance.

Creating a database and a user

Once your instance is created click on the instance name to view all details of the instance.

Here in the Overview tab, you can find the Public IP address in the Connect to this instance.

This IP address is the PostgreSQL hostname you need to provide while setting up your application.

PostgreSQL instance details

Now click on the Database tab and create a new database by clicking the Create Database button.

Get your Professional Google Cloud Architect certificate with this easy to learn course now.


Now you have created a new Cloud SQL instance for PostgreSQL on Google Cloud Platform and connected it with the Compute Engine Instance.

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.