Skip to content

Install Cloud SQL Proxy and connect to MySQL db in Ubuntu

In this post let’s see how to install cloud sql proxy and connect to a mysql database setup in Google Cloud Engine Kubernetes cluster. You should have setup gcloud in your local system before doing this.

Install cloud sql proxy

Get the latest version of cloud sql proxy from here and run the following command.

$ sudo wget -O cloud_sql_proxy


--2021-04-07 10:56:06--
Resolving ( 2404:6800:4007:80c::2010, 2404:6800:4007:80f::2010, 2404:6800:4007:82a::2010, ...
Connecting to (|2404:6800:4007:80c::2010|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15668281 (15M) [application/octet-stream]
Saving to: 'cloud_sql_proxy'

cloud_sql_proxy                                    100%[================================================================================================================>]  14.94M   351KB/s    in 98s     

2021-04-07 10:57:45 (156 KB/s) - 'cloud_sql_proxy' saved [15668281/15668281]

Give necessary permissions

$ sudo chmod +x cloud_sql_proxy

Run cloud sql proxy

$ ./cloud_sql_proxy -instances=<your-mysql-instance-name>=tcp:3306


2021/04/07 10:59:26 Rlimits for file descriptors set to {Current = 8500, Max = 1048576}
2021/04/07 10:59:36 Listening on for retina-dev:us-central1:retina-mysql-instance
2021/04/07 10:59:36 Ready for new connections

Now you can connect to your cloud mysql database in your local system using any mysql client.

See also  unable to create listener: Error listen tcp4 bind: permission denied - Fix in Ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.