Open In App

Getting Started With Cloud SQL For PostgreSQL

In the field of cloud computing, Google Cloud Platform is one of the leading players. Cloud SQL is one of the very famous services in GCP. Google Cloud SQL is a completely managed relational database service. Among the various database engines supported by Google Cloud SQL, PostgreSQL is famous for it’s reliability and wide user base. Cloud SQL for PostgreSQL provides a reliable and high-performance environment to build, manage, and scale relational databases. In this article, we will learn how we can create and connect to a PostgreSQL instance and perform operations using a cloud console and client.

What Is Cloud SQL?

Cloud SQL is a fully managed relational database management service provided by Google Cloud Platform. It offers a convenient and scalable solution for deploying and managing relational databases in the cloud. Cloud SQL supports several popular database engines like MySQL, PostgreSQL, and SQL server. User can choose their preferred database engine and use the services in the Cloud. Cloud SQL simplifies the process of deploying and managing relational databases which allows users to focus on developing their applications rather than investing time in managing database systems.



Set Up Cloud SQL For PostgreSQL Instance: A Step-By-Step Guide

Step 1: Open GCP Console

Step 2: Enable API



Step 3: Choose Database Instance

Step 4: Create PostgreSQL Instance

A) Instance Info: In place of Instance ID, give a name of your choice using the defined combinations. This is the ID given to the instance to identify it.

B) Database Version: Choose the newest version available for the selected database. Currently the latest version available for PostgreSQL is 15, which is pre-selected.

C) Choose Cloud SQL Edition: In this section, we have two edition available for cloud sql which are Enterprise Plus and Enterprise.

D) Region and Availability zone: Choose the region which is near to you or suitable for you work. You can also choose the pre-selected one if you want.

Connecting To Cloud SQL For PostgreSQL

1. Using Cloud Shell

gcloud sql connect [instance ID] --user=postgres


CREATE DATABASE guestbook;


\connect guestbook;


CREATE TABLE entries (guestName VARCHAR(255), content VARCHAR(255),
entryID SERIAL PRIMARY KEY);
INSERT INTO entries (guestName, content) values ('first guest', 'I got here!');
INSERT INTO entries (guestName, content) values ('second guest', 'Me too!');


Output

SELECT * FROM entries;


Output

2. Using PgAdmin

select * from entries;


Conclusion

Using PostgreSQL with Cloud SQL provides developers or the users a fully managed database management system for deploying, managing, and scaling PostgreSQL databases in cloud. Using Cloud SQL also helps in better integration with other Google cloud services, high availability, scalability, and better security. Overall, Google Cloud SQL for PostgreSQL provides a reliable and efficient solution for relational database management.

Cloud SQL For PostgreSQL – FAQ’s

Is Cloud Sql Is Same As Postgresql ?

Cloud SQL is a database service provided by GCP, and it supports PostgreSQL. The PostgreSQL database instance created in Cloud SQL is same as the locally available

Which Database Engines Are Supported By Cloud Sql ?

There are three database engines which are supported by Google Cloud SQL, which are,

  1. MySQL
  2. PostgreSQL
  3. SQL Server

Can I Migrate My Existing Postgresql Database To Cloud Sql?

Yes, Cloud SQL provides tools and documentations to help users migrating their existing database to Cloud SQL. There are also third-party tools available to help cloud migration.

What To Do If Pgadmin Show Connection Failed ?

This can happen if there are issues while connecting with Cloud SQL.

  1. Try changing the port number used.
  2. Check ip address and password entered is correct or not.
  3. In your cloud database add your local network’s IP.


Article Tags :