gcloud sql connect - connects to a Cloud SQL instance
gcloud sql connect INSTANCE [--database=DATABASE, -d DATABASE] [--user=USER, -u USER] [GCLOUD_WIDE_FLAG ...]
Connects to a Cloud SQL instance.
This command temporarily changes the authorized networks for this instance to allow the connection from your IP address.
This command isn't supported for Cloud SQL instances with only private IP addresses.
NOTE: If you're connecting from an IPv6 address, or are constrained by certain organization policies (restrictPublicIP, restrictAuthorizedNetworks), consider running the beta version of this command to avoid error by connecting through the Cloud SQL proxy: gcloud beta sql connect
To connect to a Cloud SQL instance, run:
$ gcloud sql connect my-instance --user=root
- INSTANCE
Cloud SQL instance ID.
- --database=DATABASE, -d DATABASE
The SQL Server database to connect to.
- --user=USER, -u USER
Cloud SQL instance user to connect as.
These flags are available to all commands: --access-token-file, --account, --billing-project, --configuration, --flags-file, --flatten, --format, --help, --impersonate-service-account, --log-http, --project, --quiet, --trace-token, --user-output-enabled, --verbosity.
Run $ gcloud help for details.
These variants are also available:
$ gcloud alpha sql connect
$ gcloud beta sql connect