Cloud SQL Basics
Cloud SQL is a fully managed relational database service for MySQL, PostgreSQL,
and SQL Server. It automates time-consuming tasks like patches, updates,
backups, and replicas, while providing high performance and availability for
your applications.
Prerequisites
Ensure you have the necessary IAM permissions to create and manage Cloud SQL
instances. The Cloud SQL Admin (roles/cloudsql.admin) role provides full
access to Cloud SQL resources.
Quick Start (PostgreSQL)
Enable the API:
gcloud services enable sqladmin.googleapis.com --quiet
Create an Instance:
gcloud sql instances create INSTANCE_NAME \
--database-version=POSTGRES_18 \
--cpu=2 \
--memory=7680MiB \
--region=REGION \
--quiet
Set a password for the default user:
Because this is a Cloud SQL for PostgreSQL instance, the default admin user
is postgres:
gcloud sql users set-password postgres \
--instance=INSTANCE_NAME --password=PASSWORD \
--quiet
Create a database:
gcloud sql databases create DATABASE_NAME \
--instance=INSTANCE_NAME \
--quiet
Get the instance connection name:
You need the instance connection name (which is formatted as
PROJECT_ID:REGION:INSTANCE_NAME) to connect using the Cloud SQL Auth
Proxy. Retrieve it with the following command:
gcloud sql instances describe INSTANCE_NAME \
--format="value(connectionName)" \
--quiet
Connect to the instance:
The Cloud SQL Auth Proxy must be running to be able to connect to the
instance. In a separate terminal, start the proxy using the connection name:
./cloud-sql-proxy INSTANCE_CONNECTION_NAME
With the proxy running, connect using psql in another terminal:
psql "host=127.0.0.1 port=5432 user=postgres dbname=DATABASE_NAME password=PASSWORD sslmode=disable"
Reference Directory
Core Concepts: Cloud SQL editions (Enterprise
& Enterprise Plus), instance architecture, read pools, high availability (HA),
and supported database engines.
CLI Usage: Essential gcloud sql commands for
instance, database, and user management.
Client Libraries & Connectors:
Connecting to Cloud SQL using Python, Java, Node.js, and Go.
MCP Usage: Using the Cloud SQL remote MCP
server and Gemini CLI extension.
Infrastructure as Code: Terraform
configuration for instances, databases, and users.
IAM & Security: Predefined roles, SSL/TLS
certificates, and Auth Proxy configuration.
Disaster Recovery & Backups: Backup types,
Point-in-Time Recovery (PITR), replicas, read pools comparison, and Enterprise Plus Advanced DR.
If you need product information not found in these references, use the
Developer Knowledge MCP server search_documents tool.
Source: google/skills → skills/cloud/cloud-sql-basics/SKILL.md
1---2name: cloud-sql-basics3description: >- This file generates or explains Cloud SQL resources. Use this file when the user asks to create a Cloud SQL instance or database for MySQL, PostgreSQL, or SQL Server. Cloud SQL manages third-party MySQL, PostgreSQL, and SQL Server instances as resources in Cloud SQL. For example, when Cloud SQL creates an open-source MySQL instance, the resulting resource is a Cloud SQL for MySQL instance that Google Cloud manages. Cloud SQL handles backups, high availability, and secure connectivity for relational database workloads.4---5
6
7# Cloud SQL Basics
8
9Cloud SQL is a fully managed relational database service for MySQL, PostgreSQL,
10and SQL Server. It automates time-consuming tasks like patches, updates,
11backups, and replicas, while providing high performance and availability for
12your applications.
13
14## Prerequisites
15
16Ensure you have the necessary IAM permissions to create and manage Cloud SQL
17instances. The **Cloud SQL Admin** (`roles/cloudsql.admin`) role provides full
18access to Cloud SQL resources.
19
20## Quick Start (PostgreSQL)
21
221. **Enable the API:**
23
24 ```bash
25 gcloud services enable sqladmin.googleapis.com --quiet
26 ```
27
282. **Create an Instance:**
29
30 ```bash
31 gcloud sql instances create INSTANCE_NAME \
32 --database-version=POSTGRES_18 \
33 --cpu=2 \
34 --memory=7680MiB \
35 --region=REGION \
36 --quiet
37 ```
38
393. **Set a password for the default user:**
40
41 Because this is a Cloud SQL for PostgreSQL instance, the default admin user
42 is `postgres`:
43
44 ```bash
45 gcloud sql users set-password postgres \
46 --instance=INSTANCE_NAME --password=PASSWORD \
47 --quiet
48 ```
49
504. **Create a database:**
51
52 ```bash
53 gcloud sql databases create DATABASE_NAME \
54 --instance=INSTANCE_NAME \
55 --quiet
56 ```
57
585. **Get the instance connection name:**
59
60 You need the instance connection name (which is formatted as
61 `PROJECT_ID:REGION:INSTANCE_NAME`) to connect using the Cloud SQL Auth
62 Proxy. Retrieve it with the following command:
63
64 ```bash
65 gcloud sql instances describe INSTANCE_NAME \
66 --format="value(connectionName)" \
67 --quiet
68 ```
69
706. **Connect to the instance:**
71
72 The Cloud SQL Auth Proxy must be running to be able to connect to the
73 instance. In a separate terminal, start the proxy using the connection name:
74
75 ```bash
76 ./cloud-sql-proxy INSTANCE_CONNECTION_NAME
77 ```
78
79 With the proxy running, connect using `psql` in another terminal:
80
81 ```bash
82 psql "host=127.0.0.1 port=5432 user=postgres dbname=DATABASE_NAME password=PASSWORD sslmode=disable"
83 ```
84
85## Reference Directory
86
87- [Core Concepts](references/core-concepts.md): Cloud SQL editions (Enterprise
88 & Enterprise Plus), instance architecture, read pools, high availability (HA),
89 and supported database engines.
90
91- [CLI Usage](references/cli-usage.md): Essential `gcloud sql` commands for
92 instance, database, and user management.
93
94- [Client Libraries & Connectors](references/client-library-usage.md):
95 Connecting to Cloud SQL using Python, Java, Node.js, and Go.
96
97- [MCP Usage](references/mcp-usage.md): Using the Cloud SQL remote MCP
98 server and Gemini CLI extension.
99
100- [Infrastructure as Code](references/iac-usage.md): Terraform
101 configuration for instances, databases, and users.
102
103- [IAM & Security](references/iam-security.md): Predefined roles, SSL/TLS
104 certificates, and Auth Proxy configuration.
105
106- [Disaster Recovery & Backups](references/dr-backups.md): Backup types,
107 Point-in-Time Recovery (PITR), replicas, read pools comparison, and Enterprise Plus Advanced DR.
108
109*If you need product information not found in these references, use the
110 Developer Knowledge MCP server `search_documents` tool.*
111
112---
113
114**Source:** [`google/skills`](https://github.com/google/skills) → `skills/cloud/cloud-sql-basics/SKILL.md`