Cloud SQL


What is Cloud SQL 

It is a fully managed relational database service for PostgreSQL and MySQL database in the GCP. MySQL instance can be deployed with a maximum of 416GB RAM and 10TB of storage, whereas PostgreSQL additionally takes up to 32CPUs with room to grow up in the future. 

datacloudies cloud sql
Cloud SQL competes with RDS service on AWS, as it is similar to traditional RDBMS, it scales up but not scale-out. Google charges you for the costs of the instance, storage, and network usage when it is deployed. For a PostgreSQL database, there is additional pricing for CPU and memory for dedicated instances. 

Features in Cloud SQL

  • Cloud SOL is a PaaS(Platform as a service) approach. 
  • No physical set up for servers or VMs. 
  • Database management tasks such as backups/archival are managed by GCP.
  • Migration from other RDBMS to Cloud SQL is relatively simple.
  • Though it is needless to say, Cloud SQL exhibits strong ACID support.
  • Instances are scalable and customizable at any time.

Creating an instance in Cloud SQL

Please do check out the video tutorial for this demonstration as well.



1.select the project and choose SQL from the menu.
datacloudies cloud sql
2. Choose the database platform as per the requirement. Select MySQL for this demo.
datacloudies cloud sql
3. setup the instance ID, password, and location. For the advanced configurations, we can select the network, machine type,  and storage type and size as per the capacity planning. Let us choose default SSD and 10GB capacity as a minimum requirement. 
datacloudies cloud sql
datacloudies cloud sql
4. Enable the automatic backups, point-in-time recovery and appropriate maintenance window will be life-saving options as per database criticality. 
datacloudies cloud sql
5. once the instance is provisioned, connect to the instance.
gcloud sql connect company
datacloudies cloud sql
6. perform database operations like create databases, tables, and so on.
create database;
show database;
create table acc_tb (
cust_id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
acc_id INT NOT NULL,
balance INT NOT NULL,
PRIMARY KEY ( cust_id ));
Insert into acc_tb values (2, “JVM”, 152, 14000);
Select * from acc_tb;
datacloudies cloud sql

Connect SQL instance through Cloud SQL Proxy

1.download the SQL proxy.
wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64
-O cloud_sql_proxy
2. change the permission.
chmod +x cloud_sql_proxy
3. connect to the SQL instance using sql proxy.
./cloud_sql_proxy –instances=<project-id>:us-central1:<instance-name>=tcp:3306
datacloudies cloud sql
4. open the mysql client and then connect to the database instance.
datacloudies cloud sql

Well, that is it. We have successfully deployed the database instance using Cloud SQL service in GCP. Please do check out the other tutorials in datacloudies. 

Recent Posts