cloud-sql-basics
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.
摘要
- 用途
- 說明 Google Cloud 的全代管關聯式資料庫服務如何執行 MySQL、PostgreSQL 與 SQL Server 工作負載,並處理維護、備份、高可用性及安全連線。
- 使用時機
- 在規劃代管資料庫的設定,或檢視如何在 Google Cloud 上管理、連線、保護或復原資料庫時參考此內容。
- 輸出結果
- 內容提供 IAM 權限前提、PostgreSQL 設定與連線步驟,以及 CLI、用戶端程式庫、MCP、Terraform、安全性、備份和災難復原的參考資料。
上游變更(11 筆,最新收錄 2026-09-21)
50eecce Improved accuracy and contents for Cloud SQL basics skills for security, CLI usage, backups and DR configurations and core concepts 擴充 Core Concepts 摘要,納入 Cloud SQL 版本方案與讀取集區,並新增 Disaster Recovery & Backups 參考項目,涵蓋備份、PITR、複本、讀取集區比較及 Enterprise Plus Advanced DR。 c75b500 Restructure the YAML frontmatter in all SKILL.md files to nest the 'category' field under the 'metadata:' block. The 'category' field is used to organize the skills in the README.md 將 Databases 類別移至 `metadata` 底下,並在多個 Quick Start 程式碼區塊前加入空行。 626910e Update gcloud examples to use --quiet. 更新 `gcloud` 範例,在啟用 API、建立執行個體、設定密碼、建立資料庫及描述執行個體時使用 `--quiet`。 6f0b877 Nests cloud/ skills under a top level skills/ directory 將檔案路徑從 `cloud/cloud-sql-basics/SKILL.md` 移至 `skills/cloud/cloud-sql-basics/SKILL.md`,內容未變。 9114a94 Flatten skill directories to work with multiple installation tools 將內容未變的技能檔案從 `cloud/products/cloud-sql/cloud-sql-basics/SKILL.md` 移至 `cloud/cloud-sql-basics/SKILL.md`。 c871830 No public description 新增 PostgreSQL 預設 `postgres` 使用者說明與查詢執行個體連線名稱的指令、更新 Auth Proxy 連線指引,並將參考文件連結改為 `references/...`。 npx skills add "lettucebo/Skills#v2.2.0@cloud-sql-basics" --full-depth ⚠ v2.2.0 發布後即可使用
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 --quietCreate an Instance:
gcloud sql instances create INSTANCE_NAME \ --database-version=POSTGRES_18 \ --cpu=2 \ --memory=7680MiB \ --region=REGION \ --quietSet 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 \ --quietCreate a database:
gcloud sql databases create DATABASE_NAME \ --instance=INSTANCE_NAME \ --quietGet 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)" \ --quietConnect 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_NAMEWith the proxy running, connect using
psqlin 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 sqlcommands 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.