Creating Instances

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

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

Creating an instance


  1. Go to the Cloud SQL Instances page in the Google Cloud Platform Console.

    Go to the Cloud SQL Instances page

  2. Click Create instance.
  3. Select PostgreSQL and click Next.
  4. Enter an ID for the instance.
    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).
  5. Enter a password for the postgres user.
  6. If needed, set any of the other optional instance settings.

    For information about the optional settings, see Instance Settings.

  7. Click Create.
  8. After the instance finishes initializing, select the instance to open it.


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

  1. Create the instance:
    gcloud beta sql instances create [INSTANCE_NAME] --database-version POSTGRES_9_6 \
           --cpu [NUMBER_CPUS] --memory [MEMORY_SIZE_IN_MBS] --activation-policy=ALWAYS

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

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

    For example, the following string creates an instance with one vCPU and 3,840 MiB of memory:

     gcloud beta sql instances create myinstance --activation-policy=ALWAYS --cpu=1 \
                                      --memory=3840MiB --database-version=POSTGRES_9_6

    You can also create a shared-core instance by using --tier db-f1-micro or --tier db-g1-small and dropping the --cpu and --memory parameters.

    For information about other available parameters, see the gcloud beta sql instances create command reference and Instance Settings.

  2. Set the password for the postgres user:
    gcloud beta sql users set-password postgres no-host --instance [INSTANCE_NAME] \
                                                             --password [PASSWORD]
  3. Retrieve the automatically assigned IPv4 address:
    gcloud beta 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.


  1. Create the instance:
    ACCESS_TOKEN="$(gcloud auth application-default print-access-token)"
    curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
         --header 'Content-Type: application/json' \
         --data '{"name":"[INSTANCE_NAME]", "region":"[REGION]",
                  "databaseVersion": "POSTGRES_9_6",
                  "settings": {"tier": "[TIER_STRING]", "activationPolicy":"ALWAYS",
                  "backupConfiguration": {"enabled":true}}}' \
         -X POST \[PROJECT-ID]/instances

    TIER_STRING is a string that represents the number of CPUs and the amount of memory you want your new instance to have. The string has the following format: db-custom-[CPUS]-[MEMORY_MBS]. You can also create a shared-core instance by supplying db-f1-micro or db-g1-small for the tier parameter.

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

  2. Update the password for the postgres user:
    curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
         --header 'Content-Type: application/json' \
         --data '{"name": "postgres", "host": "", "password": "[PASSWORD]"}' \
         -X PUT \[PROJECT-ID]/instances/[INSTANCE_NAME]/users?host=&name=postgres
  3. Retrieve the automatically assigned IPv4 address for the new instance:
    curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
         -X GET \[PROJECT-ID]/instances/[INSTANCE_NAME]
    Look for the ipAddress field in the response.

What's next

Send feedback about...

Cloud SQL for PostgreSQL