0
0
GCPcloud~5 mins

Cloud SQL supported engines (MySQL, PostgreSQL, SQL Server) in GCP - Commands & Configuration

Choose your learning style9 modes available
Introduction
Cloud SQL lets you run databases in the cloud without managing servers. It supports three popular database engines: MySQL, PostgreSQL, and SQL Server. This helps you pick the right database type for your app easily.
When you want a managed MySQL database for a web app without handling backups or updates.
When your app needs PostgreSQL features like advanced data types or full-text search.
When you have an existing SQL Server database and want to move it to the cloud with minimal changes.
When you want automatic backups, scaling, and security for your database without manual setup.
When you want to connect your cloud database to other Google Cloud services easily.
Commands
This command creates a new Cloud SQL instance using MySQL version 8.0 in the us-central1 region with a small machine type.
Terminal
gcloud sql instances create my-mysql-instance --database-version=MYSQL_8_0 --tier=db-f1-micro --region=us-central1
Expected OutputExpected
Created [https://sqladmin.googleapis.com/sql/v1beta4/projects/my-project/instances/my-mysql-instance].
--database-version - Specifies the database engine and version to use.
--tier - Defines the machine type for the instance.
--region - Sets the geographic location for the instance.
This command creates a new Cloud SQL instance using PostgreSQL version 14 in the us-central1 region with a small machine type.
Terminal
gcloud sql instances create my-postgres-instance --database-version=POSTGRES_14 --tier=db-f1-micro --region=us-central1
Expected OutputExpected
Created [https://sqladmin.googleapis.com/sql/v1beta4/projects/my-project/instances/my-postgres-instance].
--database-version - Specifies the database engine and version to use.
--tier - Defines the machine type for the instance.
--region - Sets the geographic location for the instance.
This command creates a new Cloud SQL instance using SQL Server 2019 Standard edition in the us-central1 region with a small machine type.
Terminal
gcloud sql instances create my-sqlserver-instance --database-version=SQLSERVER_2019_STANDARD --tier=db-f1-micro --region=us-central1
Expected OutputExpected
Created [https://sqladmin.googleapis.com/sql/v1beta4/projects/my-project/instances/my-sqlserver-instance].
--database-version - Specifies the database engine and version to use.
--tier - Defines the machine type for the instance.
--region - Sets the geographic location for the instance.
This command lists all Cloud SQL instances in your project to verify the created databases.
Terminal
gcloud sql instances list
Expected OutputExpected
NAME DATABASE_VERSION REGION GCE_ZONE STATUS my-mysql-instance MYSQL_8_0 us-central1 us-central1-a RUNNABLE my-postgres-instance POSTGRES_14 us-central1 us-central1-a RUNNABLE my-sqlserver-instance SQLSERVER_2019_STANDARD us-central1 us-central1-a RUNNABLE
Key Concept

If you remember nothing else, remember: Cloud SQL supports MySQL, PostgreSQL, and SQL Server engines, each created by specifying the database version during instance creation.

Common Mistakes
Using an unsupported database version string in the create command.
The command fails because Cloud SQL only accepts specific version names for each engine.
Use exact supported version strings like MYSQL_8_0, POSTGRES_14, or SQLSERVER_2019_STANDARD.
Not specifying the region flag when creating the instance.
The instance may be created in a default region that is far from your users, causing latency.
Always specify the --region flag to place the instance close to your app or users.
Trying to create multiple instances with the same name.
Cloud SQL requires unique instance names; duplicate names cause errors.
Use unique instance names for each database instance.
Summary
Create Cloud SQL instances by specifying the database engine and version with the --database-version flag.
Use the --region flag to choose where your database runs for better performance.
List your instances to check their status and confirm creation.