Stay organized with collections Save and categorize content based on your preferences.
This page describes how to connect a sqlcmd client to your Cloud SQL instance, from a client machine running Linux or Compute Engine Linux instance, using the Cloud SQL Auth Proxy Docker image.
Before you beginYou must have:
To connect using the Cloud SQL Auth Proxy Docker image:
Enable the Cloud SQL Admin API.
gcloud compute instances describe [GCE_INSTANCE_NAME]
Authenticating using scopes requires both of the following scopes:
https://www.googleapis.com/auth/sqlservice.admin
https://www.googleapis.com/auth/devstorage.read_write
Alternatively, the https://www.googleapis.com/auth/cloud-platform
scope enables all Google Cloud Platform APIs.
If your Compute Engine instance does not have the proper scopes, you can update the instance to include them. For more information, see the Compute Engine documentation.
curl https://get.docker.com | sh sudo usermod -aG docker $USER
If you are using a container-optimized Compute Engine instance, it already has the Docker client installed.
docker pull gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.18.1
scope
to connect using the Cloud SQL Admin API.
Configure the service account to have either of the following access scopes:
resourcemanager.projects.setIamPolicy
permission. This permission is included in the Project Owner, Project IAM Admin, and Organization Administrator roles.
The private key file is downloaded to your machine. You can move it to another location. Keep the key file secure.
You provide the path to the key file as "PATH_TO_KEY_FILE" when you start the Cloud SQL Auth Proxy.
Select the instance to open its Instance details page and copy the Instance connection name.
For example: myproject:us-central1:myinstance
.
Depending on your language and environment, you can start the Cloud SQL Auth Proxy using either TCP sockets or Unix sockets. Unix sockets are not supported for applications written in the Java programming language or for the Windows environment.
TCP socketsdocker run -d \ -v <PATH_TO_KEY_FILE>:/path/to/service-account-key.json \ -p 127.0.0.1:1433:1433 \ gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.18.1 \ --credentials-file /path/to/service-account-key.json <INSTANCE_CONNECTION_NAME>
If you are using the credentials provided by your Compute Engine instance, do not include the --credentials-file
parameter and the -v <PATH_TO_KEY_FILE>:/path/to/service-account-key.json
line.
Always specify 127.0.0.1
prefix in -p so that the Cloud SQL Auth Proxy is not exposed outside the local host. The "0.0.0.0" in the instances parameter is required to make the port accessible from outside of the Docker container.
docker run -d -v /cloudsql:/cloudsql \ -v <PATH_TO_KEY_FILE>:/path/to/service-account-key.json \ gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.18.1 // --unix-socket=/cloudsql \ --credentials-file /path/to/service-account-key.json <INSTANCE_CONNECTION_NAME>
If you are using the credentials provided by your Compute Engine instance, do not include the --credentials-file
parameter and the -v <PATH_TO_KEY_FILE>:/path/to/service-account-key.json
line.
If you are using a container optimized image, use a writeable directory in place of /cloudsql
, for example:
-v /mnt/stateful_partition/cloudsql:/cloudsql
You can specify more than one instance, separated by commas. You can also use Compute Engine metadata to dynamically determine the instances to connect to. Learn more about the proxy parameters.
The connection string you use depends on whether you started the Cloud SQL Auth Proxy using a TCP socket or Docker.
TCP socketssqlcmd -S tcp:127.0.0.1,1433 -U USERNAME -P PASSWORD
When you connect using TCP sockets, the Cloud SQL Auth Proxy is accessed through 127.0.0.1
.
Need help? For help troubleshooting the proxy, see
Troubleshooting Cloud SQL Auth Proxy connections, or see our
Cloud SQL Supportpage.
Keep the Cloud SQL Auth Proxy Docker image up to dateThe Cloud SQL Auth Proxy Docker image is based on a specific version of the Cloud SQL Auth Proxy. When a new version of the Cloud SQL Auth Proxy becomes available, pull the new version of the Cloud SQL Auth Proxy Docker image to keep your environment up to date. You can see the current version of the Cloud SQL Auth Proxy by checking the Cloud SQL Auth Proxy GitHub releases page. Future proxy releases will also be noted in the Google Groups Cloud SQL announce forum.
What's nextExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4