| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
The Cloud SQL Proxy allows a user with the appropriate permissions to connect to a Second Generation Cloud SQL database without having to deal with IP whitelisting or SSL certificates manually. It works by opening unix/tcp sockets on the local machine and proxying connections to the associated Cloud SQL instances when the sockets are used.
To build from source, ensure you have go installed and have set GOPATH. Then, simply do a go get:
GO111MODULE=on go get github.com/GoogleCloudPlatform/cloudsql-proxy/cmd/cloud_sql_proxy
The cloud_sql_proxy will be placed in $GOPATH/bin after go get completes.
cloud_sql_proxy takes a few arguments to configure what instances to connect to and connection behavior:
Note: -instances and -instances_metadata may be used at the same time but are not compatible with the -fuse flag.
cloud_sql_proxy authentication can be configured in a few different ways. Those listed higher on the list will override options lower on the list:
credential_file flag
token flag
Service account key at path stored in GOOGLE_APPLICATION_CREDENTIALS
gcloud user credentials (set from gcloud auth login)
Default Application Credentials via goauth:
When the proxy authenticates under the default service account of the Compute Engine VM it is running on the VM must have at least the sqlservice.admin API scope ("https://www.googleapis.com/auth/sqlservice.admin") and the associated project must have the SQL Admin API enabled. The default service account must also have at least WRITER/EDITOR priviledges to any projects of target SQL instances.
Specifying the -credential_file flag allows use of the proxy outside of Google's cloud. Simply create a new service account, download the associated JSON file, and set -credential_file to the path of the JSON file. You can also set the GOOGLE_APPLICATION_CREDENTIALS environment variable instead of passing this flag.
./cloud_sql_proxy -dir=/cloudsql -instances=my-project:us-central1:sql-inst & mysql -u root -S /cloudsql/my-project:us-central1:sql-inst # To retrieve instances from a custom metadata value (only when running on GCE) ./cloud_sql_proxy -dir=/cloudsql -instances_metadata instance/attributes/<custom-metadata-key> & mysql -u root -S /cloudsql/my-project:us-central1:sql-inst # For -fuse you do not need to specify instance names ahead of time: ./cloud_sql_proxy -dir=/cloudsql -fuse & mysql -u root -S /cloudsql/my-project:us-central1:sql-inst # For programs which do not support using Unix Domain Sockets, specify tcp: ./cloud_sql_proxy -dir=/cloudsql -instances=my-project:us-central1:sql-inst=tcp:3306 & mysql -u root -h 127.0.0.1 # For programs which require a certain Unix Domain Socket name: ./cloud_sql_proxy -dir=/cloudsql -instances=my-project:us-central1:sql-inst=unix:custom_socket_name & mysql -u root -S /cloudsql/custom_socket_name # For programs which require a the Unix Domain Socket at a specific location, set an absolute path (overrides -dir): ./cloud_sql_proxy -dir=/cloudsql -instances=my-project:us-central1:sql-inst=unix:/my/custom/sql-socket & mysql -u root -S /my/custom/sql-socket
For convenience, we maintain several containerized versions. These images are currently hosted in the following GCR repositories:
Note:
Each image is tagged with the version of the proxy it was released with. The following tags are currently supported:
Note: We strongly recommend to always use the latest version of the proxy, and to update the version regularly. However, we recommend pinning to a specific tag and avoid the latest tag. Additionally, please note that the tagged version is only that of the proxy - changes in base images may break specific setups, even on non-major version increments. As such, it's a best practice to test changes before deployment, and use automated rollbacks to revert potential failures.
Follow this page. See also Connecting from Google Kubernetes Engine.
WARNING: These distributions are not officially supported by Google.
You can find a formula for with Homebrew here.
Follow these instructions. This chart creates a Deployment and a Service, but we recommend deploying the proxy as a sidecar container in your pods.
Install via Nuget, follow these instructions.
| Back | FazBrowse Home | New Git URL |