Cloud SQL for PostgreSQL 文档
Cloud SQL for PostgreSQL 是一项全代管式数据库服务,可帮助您在 Google Cloud Platform 上设置、维护、管理和控制 PostgreSQL 关系型数据库。
了解详情
获享 $300 免费赠金开始概念验证
-
体验 Gemini 2.0 Flash Thinking
-
免费使用热门产品(包括 AI API 和 BigQuery)的每月用量
-
不会自动收费,无需承诺
继续探索 20 多种提供“始终免费”用量的产品
使用适用于常见应用场景(包括 AI API、虚拟机、数据仓库等)的 20 多种免费产品。
培训
培训和教程
将 Cloud SQL for PostgreSQL 与 Ruby on Rails 5 搭配使用
了解如何将 Ruby on Rails 5 应用连接到 Cloud SQL for PostgreSQL。
培训
培训和教程
通过 Cloud Functions 连接到 Cloud SQL
了解如何从 Cloud Functions 连接到 Cloud SQL。
使用场景
使用场景
使用 Compute Engine 和 Cloud SQL 部署 Pega
了解如何使用 Cloud SQL for PostgreSQL 部署 Pega Platform,这是一个业务流程管理和客户关系管理 (CRM) 平台。
CRM
参考架构
使用场景
使用场景
正式版发布核对清单
此核对清单提供了建议您在发布使用 Cloud SQL 的商业应用时需完成的一系列活动。本核对清单侧重于针对 Cloud SQL 的活动。
正式版
发布
使用场景
使用场景
数据驻留概览
了解如何使用 Cloud SQL 来强制执行数据的数据驻留要求。
数据驻留
数据
使用场景
使用场景
使用 Secret Manager 处理 Cloud SQL 中的 Secret
了解如何使用 Secret Manager 将有关 Cloud SQL 实例和用户的敏感信息存储为 Secret。
Secret Manager
Secret
代码示例
代码示例
Python SQLAlchemy
将 SQLAlchemy 与 Cloud SQL for PostgreSQL 数据库搭配使用
代码示例
代码示例
Node.js 示例
在 Node.js 中连接到 Cloud SQL for PostgreSQL 数据库
代码示例
代码示例
PHP PDO
使用 PHP PDO 连接 Cloud SQL for PostgreSQL 数据库
代码示例
代码示例
Go Web 应用示例
使用 Go 连接到 Cloud SQL for PostgreSQL 的简单示例
代码示例
代码示例
.NET 示例
此示例应用演示了在 Google App Engine 柔性环境中运行时如何通过 PostgreSQL 数据库将数据存储在 Google Cloud SQL 中。
代码示例
代码示例
使用 Terraform 创建具有专用网络选项的 Cloud SQL for PostgreSQL 实例。
代码示例
代码示例
Java Servlet
从 Java 应用连接到 Cloud SQL for PostgreSQL
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-23。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-23。"],[],[],null,["# Cloud SQL for PostgreSQL documentation\n======================================\n\n[Read product documentation](/sql/docs/postgres/features) Cloud SQL for PostgreSQL is a fully-managed database service that\nhelps you set up, maintain, manage, and administer your\nPostgreSQL relational databases on Google Cloud Platform.\n\n[Learn more](/sql/docs/postgres/features)\n[Get started for free](https://console.cloud.google.com/freetrial) \n\n#### Start your proof of concept with $300 in free credit\n\n- Get access to Gemini 2.0 Flash Thinking\n- Free monthly usage of popular products, including AI APIs and BigQuery\n- No automatic charges, no commitment \n[View free product offers](/free/docs/free-cloud-features#free-tier) \n\n#### Keep exploring with 20+ always-free products\n\n\nAccess 20+ free products for common use cases, including AI APIs, VMs, data warehouses,\nand more.\n\nDocumentation resources\n-----------------------\n\nFind quickstarts and guides, review key references, and get help with common issues. \nformat_list_numbered\n\n### Guides\n\n-\n\n [Create instances](/sql/docs/postgres/create-instance)\n\n-\n\n [Connection overview](/sql/docs/postgres/connect-overview)\n\n-\n\n [Enable and disable high availability on an instance](/sql/docs/postgres/configure-ha)\n\n-\n\n [Create and manage PostgreSQL databases](/sql/docs/postgres/create-manage-databases)\n\n-\n\n [Create and manage PostgreSQL users](/sql/docs/postgres/create-manage-users)\n\n-\n\n [Export and import using pg_dump, pg_dumpall, and pg_restore](/sql/docs/postgres/import-export/import-export-dmp)\n\n-\n\n [Export and import using CSV files](/sql/docs/postgres/import-export/import-export-csv)\n\n-\n\n [Create backups](/sql/docs/postgres/backup-recovery/backups)\n\n-\n\n [Create read replicas](/sql/docs/postgres/replication/create-replica)\n\n-\n\n [Build generative AI applications using Cloud SQL](/sql/docs/postgres/ai-overview)\n\nfind_in_page\n\n### Reference\n\n-\n\n [Client libraries and sample code for Cloud SQL](/sql/docs/postgres/admin-api/libraries)\n\n-\n\n [gcloud sql command-line](/sql/docs/postgres/cloud-sdk)\n\n-\n\n [Use the Cloud SQL Admin API](/sql/docs/postgres/admin-api)\n\n-\n\n [REST API](/sql/docs/postgres/admin-api/rest)\n\n-\n\n [Best practices](/sql/docs/postgres/best-practices)\n\n-\n\n [Performance tips](/sql/docs/postgres/admin-api/how-tos/performance)\n\n-\n\n [Authorize requests](/sql/docs/postgres/admin-api/how-tos/authorizing)\n\n-\n\n [Configure VPC Service Controls](/sql/docs/postgres/admin-api/configure-service-controls)\n\n-\n\n [Cloud SQL Admin API error messages](/sql/docs/postgres/admin-api-error-messages)\n\ninfo\n\n### Resources\n\n-\n\n [Pricing](/sql/docs/postgres/pricing)\n\n-\n\n [Quotas and limits](/sql/docs/postgres/quotas)\n\n-\n\n [Troubleshoot](/sql/docs/postgres/troubleshooting)\n\n-\n\n [Cloud SQL feature support by database engine](/sql/docs/feature_support)\n\n-\n\n [Release notes](/sql/docs/postgres/release-notes)\n\n-\n\n [Billing questions](/sql/docs/postgres/billing-questions)\n\n-\n\n [Getting support](/sql/docs/postgres/getting-support)\n\n-\n\n [Security bulletins](/sql/docs/postgres/security-bulletins)\n\nRelated resources\n-----------------\n\nTraining and tutorials \nUse cases \nCode samples \nExplore self-paced training, use cases, reference architectures, and code samples with examples of how to use and connect Google Cloud services. Training \nTraining and tutorials\n\n### Using Cloud SQL for PostgreSQL with Ruby on Rails 5\n\n\nLearn how to connect a Ruby on Rails 5 app to Cloud SQL for PostgreSQL.\n\n\n[Learn more](/ruby/rails/using-cloudsql-postgres) \nTraining \nTraining and tutorials\n\n### Connecting to Cloud SQL with Cloud Functions\n\n\nLearn how to connect to Cloud SQL from Cloud Functions.\n\n\n[Learn more](https://codelabs.developers.google.com/codelabs/connecting-to-cloud-sql-with-cloud-functions/) \nUse case \nUse cases\n\n### Deploying Pega using Compute Engine and Cloud SQL\n\n\nLearn how to deploy Pega Platform, which is a business process management and customer relationship management (CRM) platform with Cloud SQL for PostgreSQL.\n\nCRM Reference architecture\n\n\u003cbr /\u003e\n\n[Learn more](/solutions/deploying-pega-7-using-compute-engine-and-cloud-sql) \nUse case \nUse cases\n\n### Production launch checklist\n\n\nThis checklist provides recommended activities to complete for launching a commercial application that uses Cloud SQL. This checklist focuses on Cloud SQL-specific activities.\n\nProduction Launch\n\n\u003cbr /\u003e\n\n[Learn more](/sql/docs/postgres/launch-checklist) \nUse case \nUse cases\n\n### Data residency overview\n\n\nLearn how to use Cloud SQL to enforce data residency requirements for data.\n\nData residency data\n\n\u003cbr /\u003e\n\n[Learn more](/sql/docs/postgres/data-residency-overview) \nUse case \nUse cases\n\n### Use Secret Manager to handle secrets in Cloud SQL\n\n\nLearn how to use Secret Manager to store sensitive information about Cloud SQL instances\nand users as secrets.\n\nSecret Manager secret\n\n\u003cbr /\u003e\n\n[Learn more](/sql/docs/postgres/use-secret-manager) \nCode sample \nCode Samples\n\n### Python SQLAlchemy\n\n\nUse SQLAlchemy with your Cloud SQL for PostgreSQL database\n\n\n[Open GitHub\narrow_forward](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/cloud-sql/postgres/sqlalchemy) \nCode sample \nCode Samples\n\n### Node.js sample\n\n\nConnecting to your Cloud SQL for PostgreSQL database in Node.js\n\n\n[Open GitHub\narrow_forward](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/tree/master/cloud-sql/postgres/knex) \nCode sample \nCode Samples\n\n### PHP PDO\n\n\nConnecting your Cloud SQL for PostgreSQL database using PHP PDO\n\n\n[Open GitHub\narrow_forward](https://github.com/GoogleCloudPlatform/php-docs-samples/tree/main/cloud_sql/postgres/pdo) \nCode sample \nCode Samples\n\n### Go web app sample\n\n\nSimple examples of connecting to Cloud SQL for PostgreSQL using Go\n\n\n[Open GitHub\narrow_forward](https://github.com/GoogleCloudPlatform/golang-samples/tree/master/cloudsql/postgres/database-sql) \nCode sample \nCode Samples\n\n### .NET sample\n\n\nThis sample application demonstrates how to store data in Google Cloud SQL with a PostgreSQL database when running in Google App Engine Flexible Environment.\n\n\n[Open GitHub\narrow_forward](https://github.com/GoogleCloudPlatform/dotnet-docs-samples/tree/master/cloud-sql/postgres) \nCode sample \nCode Samples\n\n### Terraform for Cloud SQL networking\n\n\nUse Terraform to create Cloud SQL for PostgreSQL instances with private networking options.\n\n\n[Open GitHub\narrow_forward](https://github.com/GoogleCloudPlatform/cloudnetworking-config-solutions) \nCode sample \nCode Samples\n\n### Java servlet\n\n\nConnecting to Cloud SQL for PostgreSQL from a Java application\n\n\n[Open GitHub\narrow_forward](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/cloud-sql/postgres/servlet)\n\nRelated videos\n--------------\n\n### Try Cloud SQL for yourself\n\nCreate an account to evaluate how our products perform in real-world scenarios. \nNew customers also get $300 in free credits to run, test, and deploy workloads. \n[Try Cloud SQL free](https://console.cloud.google.com/freetrial)"]]