"Quickstart - Google Cloud SQL instance"

Published: Mon 04 July 2016

In content.

This page describes how to create a Google Cloud SQL instance (either First Generation or Second Generation). A Google Cloud SQL instance is a MySQL database hosted in Google's cloud.

For information about installing and getting started with the Cloud SDK, see Google Cloud SDK. For information about the Cloud Shell, see Google Cloud Shell.

  1. Show the list of potential machine types:

    gcloud sql tiers list

    Note the values that begin with db-. You must choose one of these values to create a Second Generation instance. Choosing one of the other values, such as D1, results in creating a First Generation instance.

    For information about the different machine types, their capabilities, and their effect on instance pricing, see the Pricing page. 2. Create the instance:

    gcloud sql instances create [INSTANCE_NAME] --tier\=[MACHINE_TYPE] --activation-policy\=ALWAYS

    Where MACHINE_TYPE is one of the values from the previous step that starts with db-.

    For example, the following command creates a Second Generation instance called instance1 with the machine type of db-n1-standard-8:

    gcloud sql instances create instance1 --tier=db-n1-standard-8 --activation-policy=ALWAYS

    You do not need to prepend the project ID onto the instance ID. This is done automatically where appropriate (for example, in the log files). ...see naming guidelinesFor information about other available parameters, see the gcloud sql instances createcommand reference and Instance Settings. 3. Set the password for the "root@%" MySQL user:

    gcloud sql instances set-root-password [INSTANCE_NAME] --password [PASSWORD]

  2. Retrieve the automatically assigned IPv4 address:

    gcloud sql instances describe [INSTANCE_NAME]

    In the output, find the ipAddress field. You can use this as the IP address your applications or tools use to connect to the instance.