Skip to main content
bqto connects to Cloud SQL instances with a private IP, through private services access (PSA) or Private Service Connect (PSC). Read replicas work too. This service is in the free bqto.

Connect

--instance takes the name of the instance. cloudsql is the default service, so you can leave out --service. bqto gives you a port forward. The local port is the port of the instance plus 10000, so 5432 becomes 15432. The try: line gives a command for the client:

Clients

When you run a command through the session with -- CMD, the command gets these variables:
The database login is separate from bqto. bqto carries no database password. You type it into your own client.

What it needs

  • The API sqladmin.googleapis.com in the service project.
  • The role roles/cloudsql.viewer in the service project, together with the roles that every session needs. See Permissions.

Connection logs

To match a connection in the database to a session, turn on the connection log of the instance. These flags come from Google’s documentation and were not tested live.
Each flag writes to the logs of the instance in Cloud Logging. Each has a cost in log volume. For MySQL, the flag also costs instance performance.

Check the server certificate

With --endpoint, bqto prints a try: line with sslmode=require. That mode encrypts the connection, but it does not check a certificate. To check the certificate, download the server CA of the instance into server-ca.pem. With the default per-instance CA, each instance has its own CA, so it is enough to check the CA. The certificate holds the DNS name of the instance only on Private Service Connect instances.
With the shared CA or a customer-managed CA, the certificate holds the DNS name of the instance. With the shared CA, check the hostname too. libpq checks host and connects to hostaddr:
See Cloud SQL server CA modes.