项目文件夹

文件
wehub-resource-sync bb5c75ce05
Component Security Validation / Security Audit (push) Has been cancelled
Deploy to Cloudflare Pages / deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:38:58 +08:00

1 行
3.3 KiB
JSON

{"content": "---\nname: cloud-sql-basics\ndescription: Creates and manages Cloud SQL instances for MySQL, PostgreSQL, and SQL Server. Handles backups, high availability, and secure connectivity for relational database workloads on Google Cloud.\nsource: google/skills (Apache 2.0)\n---\n\n# Cloud SQL Basics\n\nCloud SQL is a fully managed relational database service for MySQL, PostgreSQL,\nand SQL Server. It automates time-consuming tasks like patches, updates,\nbackups, and replicas, while providing high performance and availability for\nyour applications.\n\n## Prerequisites\n\nEnsure you have the necessary IAM permissions to create and manage Cloud SQL\ninstances. The **Cloud SQL Admin** (`roles/cloudsql.admin`) role provides full\naccess to Cloud SQL resources.\n\n## Quick Start (PostgreSQL)\n\n1. **Enable the API:**\n ```bash\n gcloud services enable sqladmin.googleapis.com --quiet\n ```\n\n2. **Create an Instance:**\n ```bash\n gcloud sql instances create INSTANCE_NAME \\\n --database-version=POSTGRES_18 \\\n --cpu=2 \\\n --memory=7680MiB \\\n --region=REGION \\\n --quiet\n ```\n\n3. **Set a password for the default user:**\n\n Because this is a Cloud SQL for PostgreSQL instance, the default admin user\n is `postgres`:\n ```bash\n gcloud sql users set-password postgres \\\n --instance=INSTANCE_NAME --password=PASSWORD \\\n --quiet\n ```\n\n4. **Create a database:**\n ```bash\n gcloud sql databases create DATABASE_NAME \\\n --instance=INSTANCE_NAME \\\n --quiet\n ```\n\n5. **Get the instance connection name:**\n\n You need the instance connection name (which is formatted as\n `PROJECT_ID:REGION:INSTANCE_NAME`) to connect using the Cloud SQL Auth\n Proxy. Retrieve it with the following command:\n ```bash\n gcloud sql instances describe INSTANCE_NAME \\\n --format=\"value(connectionName)\" \\\n --quiet\n ```\n\n6. **Connect to the instance:**\n\n The Cloud SQL Auth Proxy must be running to be able to connect to the\n instance. In a separate terminal, start the proxy using the connection name:\n ```bash\n ./cloud-sql-proxy INSTANCE_CONNECTION_NAME\n ```\n\n With the proxy running, connect using `psql` in another terminal:\n ```bash\n psql \"host=127.0.0.1 port=5432 user=postgres dbname=DATABASE_NAME password=PASSWORD sslmode=disable\"\n ```\n\n## Reference Directory\n\n- [Core Concepts](references/core-concepts.md): Instance architecture, high\n availability (HA), and supported database engines.\n\n- [CLI Usage](references/cli-usage.md): Essential `gcloud sql` commands for\n instance, database, and user management.\n\n- [Client Libraries & Connectors](references/client-library-usage.md):\n Connecting to Cloud SQL using Python, Java, Node.js, and Go.\n\n- [MCP Usage](references/mcp-usage.md): Using the Cloud SQL remote MCP\n server and Gemini CLI extension.\n\n- [Infrastructure as Code](references/iac-usage.md): Terraform\n configuration for instances, databases, and users.\n\n- [IAM & Security](references/iam-security.md): Predefined roles, SSL/TLS\n certificates, and Auth Proxy configuration.\n\n*If you need product information not found in these references, use the\n Developer Knowledge MCP server `search_documents` tool.*\n"}