1

I'm making a connection between a Google Compute Engine instance and a Google Cloud SQL instance, using the Cloud SQL Proxy. Using this tutorial, I have managed to establish a connection by running this command:

./cloud_sql_proxy -instances=<INSTANCE_CONNECTION_NAME>=tcp:3306

However, when I quit the terminal instance I used to enter the above command the connection is lost.

How can i keep the connection alive throughout?

fbraga
  • 711
  • 4
  • 9
Makamu Evans
  • 491
  • 1
  • 10
  • 25
  • Can you rephrase "However, when I quit the terminal instance I used to enter the above command the connection is lost.". It's difficult to understand what you mean. – fbraga Mar 27 '19 at 14:59
  • Keep in mind that to connect with the Cloud SQL instance using the Cloud SQL Proxy, the cloud_sql_proxy must be running in it. – fbraga Mar 27 '19 at 15:02

1 Answers1

1

If you want the process of cloud_sql_proxy to run as long as the Google Compute Engine (GCE) instance is running, just make the process run in the background. For that you just add the '&' character in the end of your command, so i would go like this:

./cloud_sql_proxy -instances=<INSTANCE_CONNECTION_NAME>=tcp:3306&

This way, as along as you don't stop the GCE instance, you can ssh to it and connect to your Cloud SQL instance (with INSTANCE_CONNECTION_NAME) with the Cloud SQL Proxy being used.

fbraga
  • 711
  • 4
  • 9