Create instances

This page describes how to create a Cloud SQL for MySQL instance.

For detailed information about all instance settings, see Instance Settings.

A newly-created instance has four system databases:

  • information_schema: Provides access to database metadata, information about the MySQL server.
  • mysql: The system schema. It contains tables that store information required by the MySQL server as it runs.
  • performance_schema: A feature for monitoring MySQL Server execution at a low level.
  • sys: Contains a set of objects that helps DBAs and developers interpret data collected by the performance schema.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Cloud project. Learn how to check if billing is enabled on a project.

  4. Install and initialize the Google Cloud CLI.
  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Make sure that billing is enabled for your Cloud project. Learn how to check if billing is enabled on a project.

  7. Install and initialize the Google Cloud CLI.
  8. Make sure you have the Cloud SQL Admin and Compute Viewer roles on your user account.

    Go to the IAM page

    Learn more about roles and permissions.

Create a MySQL instance

Console

  1. In the Google Cloud console, go to the Cloud SQL Instances page.

    Go to Cloud SQL Instances

  2. Click Create instance.
  3. On the Choose your database engine panel of the Create an instance page, click Choose MySQL and click Next.
  4. In the Instance ID field of the Instance info pane, enter an ID for your instance.

    Do not include sensitive or personally identifiable information in your instance name; it is externally visible.

    You do not need to include the project ID in the instance name. This is done automatically where appropriate (for example, in the log files).

  5. Set a password for the root user. You can either enter the password manually or you can click Generate to have Cloud SQL create a password for you automatically.

    Tip: To see the password in clear text, click the Show password icon.

    Although there is an option to set No password, this is not recommended for security reasons.

  6. Select the database version for your instance: MySQL 8.0 (default), MySQL 5.7, or MySQL 5.6.

    The database version cannot be edited after the instance has been created.

  7. In the Choose region and zonal availability section, select the region and zone for your instance.

    Place your instance in the same region as the resources that access it. The region you select can't be modified in the future. In most cases, you don't need to specify a zone.

    If you are configuring your instance for high availability, you can select both a primary and secondary zone.

    The following conditions apply when the secondary zone is used during instance creation:

    • The zones default to Any for the primary zone and Any (different from primary) for the secondary zone.
    • If both the primary and secondary zones are specified, they must be distinct zones.
  8. In the Customize your instance section, update settings for your instance. Begin by clicking SHOW CONFIGURATION OPTIONS to display the groups of settings. Then, expand desired groups to review and customize settings. A Summary of all the options you select is shown on the right. Customizing these instance settings is optional. Defaults are assigned in every case where no customizations are made.

    The following table is a quick reference to instance settings. For more details about each setting, see the instance settings page.

    Setting Notes
    Machine type
    Machine type Select from Shared core, Lightweight, Standard (Most common), or High memory.
    Custom Select this button to create an instance with a custom configuration. When you select this option, you need to select the number of cores and amount of memory for your instance. Learn more.
    Cores The number of vCPUs for your instance. Learn more.
    Memory The amount of memory for your instance, in GBs. Learn more.
    Storage
    Storage type Determines whether your instance uses SSD or HDD storage. Learn more.
    Storage capacity The amount of storage provisioned for the instance. Learn more.
    Enable automatic storage increases Determines whether Cloud SQL automatically provides more storage for your instance when free space runs low. Learn more.
    Encryption
    Google-managed encryptionThe default option.
    Customer key-managed encryption key (CMEK)Select to use your key with Google Cloud Key Management Service. Learn more.
    Connectivity
    Private IP Adds a private IP address for your instance. To enable connecting to the instance, additional configuration is required.
    Optionally, you can specify an allocated IP range for your instances to use for connections.
    1. Expand Show allocated IP range option.
    2. Select an IP range from the drop-down menu.

    Your instance can have both a public and a private IP address.

    Public IP Adds a public IP address for your instance. You can then add authorized networks to connect to the instance.

    Your instance can have both a public and a private IP address.

    Learn more about using public IP.

    Authorized networksAdd the name for the new network and the Network address. Learn more.
    Backups
    Automate backups The window of time when you would like backups to start. Learn more.
    Choose where to store your backupsSelect Multi-region for most use cases. If you need to store backups in a specific region, for example, if there are regulatory reasons to do so, select Region and select your region from the Location drop-down menu.
    Choose how many automated backups to storeThe number of automated backups you would like to retain (from 1 to 365 days). Learn more.
    Enable point-in-time recovery Enables point-in-time recovery and write-ahead logging. Learn more.
    Choose how many days of logs to retain Configure write-ahead log retention from 1 to 7 days. The default setting is 7 days. Learn more.
    Maintenance
    Preferred window Determines a one-hour window when Cloud SQL can perform disruptive maintenance on your instance. If you do not set the window, then disruptive maintenance can be done at any time. Learn more.
    Order of updates Your preferred timing for instance updates, relative to other instances in the same project. Learn more.
    Flags
    ADD FLAG You can use database flags to control settings and parameters for your instance. Learn more.
    Labels
    ADD LABELAdd a key and value for each label that you add. You use labels to help organize your instances.
  9. Click Create Instance.

    Note: It might take a few minutes to create your instance. However, you can view information about the instance while it's being created.

gcloud

For information about installing and getting started with the gcloud, see Installing gcloud CLI. For information about starting Cloud Shell, see the Cloud Shell documentation.

  1. Create the instance:
    gcloud sql instances create INSTANCE_NAME \
    --cpu=NUMBER_CPUS \
    --memory=MEMORY_SIZE \
    --region=REGION
    
    Or, alternatively, you can use the --tier flag if you choose db-f1-micro or db-g1-small as the machine type:
    gcloud sql instances create INSTANCE_NAME \
    --tier=API_TIER_STRING \
    --region=REGION
    

    There are restrictions on the values for vCPUs and memory size:

    • vCPUs must be either 1 or an even number between 2 and 96.
    • Memory must be:
      • 0.9 to 6.5 GB per vCPU
      • A multiple of 256 MB
      • At least 3.75 GB (3840 MB)

    For example, the following string creates an instance with two vCPUs and 7,680 MB of memory:

    gcloud sql instances create myinstance \
    --database-version=MYSQL_8_0 \
    --cpu=2 \
    --memory=7680MB \
    --region=us-central1
    

    The default value for REGION is us-central.

    Do not include sensitive or personally identifiable information in your instance name; it is externally visible.
    You do not need to include the project ID in the instance name. This is done automatically where appropriate (for example, in the log files).

    If you are creating an instance for high availability, you can specify both the primary and secondary zones, using the --zone and --secondary-zone parameters. The following conditions apply when the secondary zone is used during instance creation or edit:

    • The zones must be valid zones.
    • If the secondary zone is specified, the primary must also be specified.
    • If the primary and secondary zones are specified, they must be distinct zones.
    • If the primary and secondary zones are specified, they must belong to the same region.

    You can add more parameters to determine other instance settings:

    Setting Parameter Notes
    Required parameters
    Database version --database-version The database version, which can be one of the following:
    • MYSQL_8_0 (default major version)
    • MYSQL_8_0_28
    • MYSQL_8_0_27
    • MYSQL_8_0_26 (default minor version for MySQL 8.0)
    • MYSQL_8_0_18
    • MYSQL_5_7
    • MYSQL_5_6
    Region --region See valid values.
    Connectivity
    Private IP --network

    --no-assign-ip (optional)

    --allocated-ip-range-name (optional)

    --network: Specifies the name of the VPC network you want to use for this instance. Private services access must already be configured for the network. Available only for the beta command (gcloud beta sql instances create).

    --no-assign-ip: Instance will only have a private IP address.

    --allocated-ip-range-name: If specified, sets a range name for which an IP range is allocated. For example, google-managed-services-default. The range name should comply with RFC-1035 and be within 1-63 characters. (gcloud alpha sql instances create).

    Learn more about configuring private IP.
    Public IP --authorized-networks For public IP connections, only connections from authorized networks can connect to your instance. Learn more.
    Machine type and storage
    Machine type --tier Used to specify a shared-core instance (db-f1-micro or db-g1-small). For a custom instance configuration, use the --cpu or --memory parameters instead. See Custom instance configuration.
    Storage type --storage-type Determines whether your instance uses SSD or HDD storage. Learn more.
    Storage capacity --storage-size The amount of storage provisioned for the instance, in GB. Learn more.
    Automatic storage increase --storage-auto-increase Determines whether Cloud SQL automatically provides more storage for your instance when free space runs low. Learn more.
    Automatic storage increase limit --storage-auto-increase-limit Determines how large Cloud SQL can automatically grow storage. Available only for the beta command (gcloud beta sql instances create). Learn more.
    Automatic backups and high availability
    High availability --availability-type For a highly-available instance, set to REGIONAL. Learn more.
    Secondary zone --secondary-zone If you are creating an instance for high availability, you can specify both the primary and secondary zones using the >--zone and --secondary-zone parameters. The following restrictions apply when the secondary zone is used during instance creation or edit:
    • The zones must be valid zones.
    • If the secondary zone is specified, the primary must also be specified.
    • If the primary and secondary zones are specified, they must be distinct zones.

      If the primary and secondary zones are specified, they must belong to the same region.

    Automatic backups --backup-start-time The window of time when you would like backups to start. Learn more.
    Retention settings for automated backups --retained-backups-count The number of automated backups to retain. Learn more.
    Binary logging --enable-bin-log Binary logging enables replication and point-in-time recovery. Learn more.
    Retention settings for binary logging --retained-transaction-log-days The number of days to retain binary logs for point-in-time recovery.Learn more.
    Add database flags
    Database flags --database-flags You can use database flags to control settings and parameters for your instance. Learn more about database flags. Learn more about how to format this parameter.
    Maintenance schedule
    Maintenance window --maintenance-window-day,
    --maintenance-window-hour
    Determines a one-hour window when Cloud SQL can perform disruptive maintenance on your instance. If you do not set the window, then disruptive maintenance can be done at any time. Learn more.
    Maintenance timing --maintenance-release-channel Your preferred timing for instance updates, relative to other instances in the same project. Use preview for earlier updates, and production for later updates. Learn more.
  2. Note the automatically assigned IP address.

    If you are not using the Cloud SQL Auth proxy, you will use this address as the host address that your applications or tools use to connect to the instance.

  3. Set the password for the "root@%" MySQL user:
    gcloud sql users set-password root \
    --host=% \
    --instance INSTANCE_NAME \
    --password PASSWORD
    

Terraform

To create an instance, use a Terraform resource.

resource "google_sql_database_instance" "instance" {
  name             = "mysql-instance"
  region           = "us-central1"
  database_version = "MYSQL_8_0"
  settings {
    tier = "db-n1-standard-2"
  }
  deletion_protection =  "true"
}

REST v1

Create the instance

This example creates an instance with backups and binary logging enabled. These settings are optional. For a complete list of parameters for this call, see the Instances:insert page. For information about instance settings, including valid values for region, see Instance Settings.

Do not include sensitive or personally identifiable information in your instance ID; it is externally visible.
You do not need to include the project ID in the instance name. This is done automatically where appropriate (for example, in the log files).

Before using any of the request data, make the following replacements:

  • project-id: your project ID
  • instance-id: desired instance ID
  • database-version: The database version. For example: MYSQL_8.0 or MYSQL_8_0_18.
  • region: desired region
  • machine-type: desired machine type

HTTP method and URL:

POST https://sqladmin.googleapis.com/v1/projects/project-id/instances

Request JSON body:

{
  "name": "instance-id",
  "region": "region",
  "databaseVersion": "database-version",
  "settings": {
    "tier": "machine-type",
    "backupConfiguration": {
      "binaryLogEnabled": true,
      "enabled": true
    }
  }
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "kind": "sql#operation",
  "targetLink": "https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id",
  "status": "PENDING",
  "user": "user@example.com",
  "insertTime": "2019-09-25T22:19:33.735Z",
  "operationType": "CREATE",
  "name": "operation-id",
  "targetId": "instance-id",
  "selfLink": "https://sqladmin.googleapis.com/v1/projects/project-id/operations/operation-id",
  "targetProject": "project-id"
}

The response is a long-running operation, which might take a few minutes to complete.

Update the root password

When the instance finishes initializing, update the root password:

Before using any of the request data, make the following replacements:

  • project-id: your project ID
  • instance-id: instance ID created in prior step
  • root-password: desired root password

HTTP method and URL:

PUT https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id/users?host=%25&name=root

Request JSON body:

{
  "name": "root",
  "host": "%",
  "password": "root-password"
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "kind": "sql#operation",
  "targetLink": "https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id",
  "status": "DONE",
  "user": "user@example.com",
  "insertTime": "2019-09-26T14:32:30.592Z",
  "startTime": "2019-09-26T14:32:30.594Z",
  "endTime": "2019-09-26T14:32:33.518Z",
  "operationType": "UPDATE_USER",
  "name": "operation-id",
  "targetId": "instance-id",
  "selfLink": "https://sqladmin.googleapis.com/v1/projects/project-id/operations/operation-id",
  "targetProject": "project-id"
}

The response is a long-running operation, which might take a few minutes to complete.

Retrieve the IPv4 address

Retrieve the automatically assigned IPv4 address for the new instance:

Before using any of the request data, make the following replacements:

  • project-id: your project ID
  • instance-id: instance ID created in prior step

HTTP method and URL:

GET https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "kind": "sql#instance",
  "state": "RUNNABLE",
  "databaseVersion": "MYSQL_8_0_18",
  "settings": {
    "authorizedGaeApplications": [],
    "tier": "db-f1-micro",
    "kind": "sql#settings",
    "pricingPlan": "PER_USE",
    "replicationType": "SYNCHRONOUS",
    "activationPolicy": "ALWAYS",
    "ipConfiguration": {
      "authorizedNetworks": [],
      "ipv4Enabled": true
    },
    "locationPreference": {
      "zone": "us-west1-a",
      "kind": "sql#locationPreference"
    },
    "dataDiskType": "PD_SSD",
    "backupConfiguration": {
      "startTime": "18:00",
      "kind": "sql#backupConfiguration",
      "enabled": true,
      "binaryLogEnabled": true
    },
    "settingsVersion": "1",
    "storageAutoResizeLimit": "0",
    "storageAutoResize": true,
    "dataDiskSizeGb": "10"
  },
  "etag": "--redacted--",
  "ipAddresses": [
    {
      "type": "PRIMARY",
      "ipAddress": "10.0.0.1"
    }
  ],
  "serverCaCert": {
    ...
  },
  "instanceType": "CLOUD_SQL_INSTANCE",
  "project": "project-id",
  "serviceAccountEmailAddress": "redacted@gcp-sa-cloud-sql.iam.gserviceaccount.com",
  "backendType": "SECOND_GEN",
  "selfLink": "https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id",
  "connectionName": "project-id:region:instance-id",
  "name": "instance-id",
  "region": "us-west1",
  "gceZone": "us-west1-a"
}

Look for the ipAddress field in the response.

REST v1beta4

Create the instance

This example creates an instance with backups and binary logging enabled. These settings are optional. For a complete list of parameters for this call, see the Instances:insert page. For information about instance settings, including valid values for region, see Instance Settings.

Do not include sensitive or personally identifiable information in your instance ID; it is externally visible.
You do not need to include the project ID in the instance name. This is done automatically where appropriate (for example, in the log files).

Before using any of the request data, make the following replacements:

  • project-id: your project ID
  • instance-id: desired instance ID
  • database-version: The database version. For example: MYSQL_8.0 or MYSQL_8_0_18.
  • region: desired region
  • machine-type: desired machine type

HTTP method and URL:

POST https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances

Request JSON body:

{
  "name": "instance-id",
  "region": "region",
  "databaseVersion": "database-version",
  "settings": {
    "tier": "machine-type",
    "backupConfiguration": {
      "binaryLogEnabled": true,
      "enabled": true
    }
  }
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "kind": "sql#operation",
  "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id",
  "status": "PENDING",
  "user": "user@example.com",
  "insertTime": "2019-09-25T22:19:33.735Z",
  "operationType": "CREATE",
  "name": "operation-id",
  "targetId": "instance-id",
  "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/operations/operation-id",
  "targetProject": "project-id"
}

The response is a long-running operation, which might take a few minutes to complete.

Update the root password

When the instance finishes initializing, update the root password:

Before using any of the request data, make the following replacements:

  • project-id: your project ID
  • instance-id: instance ID created in prior step
  • root-password: desired root password

HTTP method and URL:

PUT https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id/users?host=%25&name=root

Request JSON body:

{
  "name": "root",
  "host": "%",
  "password": "root-password"
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "kind": "sql#operation",
  "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id",
  "status": "DONE",
  "user": "user@example.com",
  "insertTime": "2019-09-26T14:32:30.592Z",
  "startTime": "2019-09-26T14:32:30.594Z",
  "endTime": "2019-09-26T14:32:33.518Z",
  "operationType": "UPDATE_USER",
  "name": "operation-id",
  "targetId": "instance-id",
  "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/operations/operation-id",
  "targetProject": "project-id"
}

The response is a long-running operation, which might take a few minutes to complete.

Retrieve the IPv4 address

Retrieve the automatically assigned IPv4 address for the new instance:

Before using any of the request data, make the following replacements:

  • project-id: your project ID
  • instance-id: instance ID created in prior step

HTTP method and URL:

GET https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "kind": "sql#instance",
  "state": "RUNNABLE",
  "databaseVersion": "MYSQL_8_0_18",
  "settings": {
    "authorizedGaeApplications": [],
    "tier": "db-f1-micro",
    "kind": "sql#settings",
    "pricingPlan": "PER_USE",
    "replicationType": "SYNCHRONOUS",
    "activationPolicy": "ALWAYS",
    "ipConfiguration": {
      "authorizedNetworks": [],
      "ipv4Enabled": true
    },
    "locationPreference": {
      "zone": "us-west1-a",
      "kind": "sql#locationPreference"
    },
    "dataDiskType": "PD_SSD",
    "backupConfiguration": {
      "startTime": "18:00",
      "kind": "sql#backupConfiguration",
      "enabled": true,
      "binaryLogEnabled": true
    },
    "settingsVersion": "1",
    "storageAutoResizeLimit": "0",
    "storageAutoResize": true,
    "dataDiskSizeGb": "10"
  },
  "etag": "--redacted--",
  "ipAddresses": [
    {
      "type": "PRIMARY",
      "ipAddress": "10.0.0.1"
    }
  ],
  "serverCaCert": {
    ...
  },
  "instanceType": "CLOUD_SQL_INSTANCE",
  "project": "project-id",
  "serviceAccountEmailAddress": "redacted@gcp-sa-cloud-sql.iam.gserviceaccount.com",
  "backendType": "SECOND_GEN",
  "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id",
  "connectionName": "project-id:region:instance-id",
  "name": "instance-id",
  "region": "us-west1",
  "gceZone": "us-west1-a"
}

Look for the ipAddress field in the response.

To see how the underlying REST API request is constructed for this task, see the APIs Explorer on the instances:insert page.

Specify the database minor version

You can specify the minor version of an existing instance by using gcloud or the REST API.

gcloud

Use the gcloud sql instances create command with the --database-version flag.

Replace the following variables before running the command:

  • INSTANCE_NAME: The name of the instance.
  • DATABASE_VERSION: The database minor version of the instance: MYSQL_8_0_18, MYSQL_8_0_26 (default minor version for MySQL 8.0), MYSQL_8_0_27, or MYSQL_8_0_28. If you specify MYSQL_8_0, the default minor version is used. If you don't specify this flag, the default major version, MYSQL_5_7, is used.
gcloud sql instances create INSTANCE_NAME \
--database-version=DATABASE_VERSION

For detailed information, see the documentation on creating an instance by using gcloud.

REST v1

Use a POST request with the instances:insert method and the databaseVersion flag.

    POST https://sqladmin.googleapis.com/sql/v1/projects/project-id/instances
Before using any of the request data, replace these variables:
  • project_id: The ID of the project.
  • instance_id: The name of the instance.
  • databaseVersion: The database version of the instance: MYSQL_8_0_18, MYSQL_8_0_26 (default minor version for MySQL 8.0), MYSQL_8_0_27, or MYSQL_8_0_28. If you specify MYSQL_8_0, the default minor version is used. If you don't specify this flag, the default major version, MYSQL_5_7, is used. See for a list of valid values.

For detailed information, see the documentation on creating an instance by using the REST v1 API.

REST v1beta4

Use a POST request with the instances:insert method and the databaseVersion flag.

    POST https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances
Before using any of the request data, replace these variables:
  • project_id: The ID of the project.
  • instance_id: The name of the instance.
  • databaseVersion: The database version of the instance: MYSQL_8_0_18, MYSQL_8_0_26 (default minor version for MySQL 8.0), MYSQL_8_0_27, or MYSQL_8_0_28. If you specify MYSQL_8_0, the default minor version is used. If you don't specify this flag, the default major version, MYSQL_5_7, is used.

For detailed information, see the documentation on for creating an instance by using the REST v1beta4 API.

Database minor version for read replicas, clones, and PITR

When creating a read replica, you can specify the database minor version of the read replica. By default, new read replicas are created on the default minor version.

When cloning an instance, the newly created instance has that same minor version as that of the source.

When performing a point-in-time recovery, the newly created instance has the same database minor version as that of the source.

Custom instance configurations

Custom instance configurations let you select the amount of memory and CPUs that your instance needs. This flexibility lets you choose the appropriate VM shape for your workload.

Machine type names use the following format: db-custom-#-#

Replace the first # placeholder with the number of CPUs in the machine, and the second # placeholder with the amount of memory in the machine.

For example, if your machine name is db-custom, and your machine has 1 CPU and 3840 MB of RAM, then the format for the machine would be db-custom-1-3840.

When selecting the number of CPUs and amount of memory, there are some restrictions on the configuration you choose:

  • vCPUs must be either 1 or an even number between 2 and 96.
  • Memory must be:
    • 0.9 to 6.5 GB per vCPU
    • A multiple of 256 MB
    • At least 3.75 GB (3840 MB)

The following table lists the names of each legacy machine type, the number of CPUs and RAM for each machine type, and the resultant string for the machine type.

You can create the equivalent machine type by specifying the equivalent CPU and RAM in the Google Cloud console, by using the gcloud CLI, or by specifying db-custom-#-# in the API.

Legacy machine type vCPUs Memory (MBs) db-custom-CPU-RAM string (API tier string)
db-n1-standard-1 1 3840 db-custom-1-3840
db-n1-standard-2 2 7680 db-custom-2-7680
db-n1-standard-4 4 15360 db-custom-4-15360
db-n1-standard-8 8 30720 db-custom-8-30720
db-n1-standard-16 16 61440 db-custom-16-61440
db-n1-standard-32 32 122880 db-custom-32-122880
db-n1-standard-64 64 245760 db-custom-64-245760
db-n1-standard-96 96 368640 db-custom-96-368640
db-n1-highmem-2 2 13312 db-custom-2-13312
db-n1-highmem-4 4 26624 db-custom-4-26624
db-n1-highmem-8 8 53248 db-custom-8-53248
db-n1-highmem-16 16 106496 db-custom-16-106496
db-n1-highmem-32 32 212992 db-custom-32-212992
db-n1-highmem-64 64 425984 db-custom-64-425984
db-n1-highmem-96 96 638976 db-custom-96-638976

Troubleshoot

Issue Troubleshooting
You get the error message: Failed to create subnetwork. Couldn't find free blocks in allocated IP ranges. Please allocate new ranges for this service provider. There are no more available addresses in the allocated IP range. There can be several possible scenarios:

  • The size of the allocated IP range for the private service connection is smaller than /24.
  • The size of the allocated IP range for the private service connection is too small for the number of Cloud SQL instances.
  • The requirement on the size of allocated IP range will be larger if instances are created in multiple regions. See allocated range size

For each of the above scenarios you can elect to either expand the existing allocated IP range or allocate an additional IP range to the private service connection.

If you used the --allocated-ip-range-name flag while creating the Cloud SQL instance, you may only expand the specified IP range.

If you're allocating a new range, take care that the allocation doesn't overlap with any existing allocations.

After creating a new IP range, update the vpc peering with the following command:

gcloud services vpc-peerings update \
--service=servicenetworking.googleapis.com \
--ranges=OLD_RESERVED_RANGE_NAME,NEW_RESERVED_RANGE_NAME \
--network=VPC_NETWORK \
--project=PROJECT_ID \
--force
    

If you're expanding an existing allocation, take care to increase only the allocation range and not decrease it. For example, if the original allocation was 10.0.10.0/24, then make the new allocation at least 10.0.10.0/23.

In general, if starting from a /24 allocation, decrementing the /mask by 1 for each condition (additional instance type group, additional region) is a good rule of thumb. For example, if trying to create both instance type groups on the same allocation, going from /24 to /23 is enough.

After expanding an existing IP range, update the vpc peering with following command:

gcloud services vpc-peerings update \
--service=servicenetworking.googleapis.com \
--ranges=RESERVED_RANGE_NAME \
--network=VPC_NETWORK \
--project=PROJECT_ID
    

What's next

  1. Create a MySQL database on the instance.
  2. Create MySQL users on the instance.
  3. Secure and control access to the instance.
  4. Connect to the instance with a MySQL client.
  5. Import data into the database.