Accessing Cloud SQL from local mysql client using cloud sql auth proxy

140 views Asked by At

I have a problem in connecting to my Cloud SQL - MySQL instance from local / gcloud shell. As per org policy we cannot have public IP for the mysql db instance. so I created a vpc network to use with this instance which created a private IP access only.

Now I am running cloud sql auth proxy and trying to connect to this instance with mysql client on my local. But it stills fails with error failed to connect to instance: Config error: instance does not have IP of type "PUBLIC"

Here is the connection test output:

./cloud-sql-proxy --run-connection-test --credentials-file <file> <instance connection name>
2024/01/08 22:13:03 Authorizing with the credentials file at “f”file
2024/01/08 22:13:04 [<instance connection name>] Listening on 127.0.0.1:3306
2024/01/08 22:13:04 The proxy has started successfully and is ready for new connections!
2024/01/08 22:13:04 Connection test started
2024/01/08 22:13:04 Connection test failed
2024/01/08 22:13:04 The proxy has encountered a terminal error: Config error: instance does not have IP of type "PUBLIC" (connection name = "instance connection name")

Can you please help?

1

There are 1 answers

0
Vinay On

Followed the documentation: https://cloud.google.com/sql/docs/mysql/connect-instance-private-ip to create a Compute Engine VM (the source) within the same VPC network where mySQL is running and access MySQL from there.