简体   繁体   中英

GCP using VM to connect to Cloud SQL via Cloud SQL Auth Proxy Private IP

I am having problems connecting a GCP Compute Engine VM to a Cloud SQL instance configured with private IP (no public) via Cloud SQL Auth Proxy .

After executing

$ ./cloud_sql_proxy -instances=INSTANCE_CONN_NAME=tcp:3306

I see the following output:

2021/10/11 12:29:24 Rlimits for file descriptors set to {Current = 8500, Max = 1048576}

2021/10/11 12:29:28 Listening on 127.0.0.1:3306 for *CLOUD-SQL-CONNECTION-NAME*

2021/10/11 12:29:28 Ready for new connections

2021/10/11 12:29:28 Generated RSA key in 101.010024ms

I haven't seen the final statement on the above on any of the tutorials I have read on this subject.

I CTRL-C out of the above, and I am shown:

^C2021/10/11 12:29:39 Received TERM signal. Waiting up to 0s before terminating.

I then run the below command to connect to my Cloud SQL instance:

mysql -u root -p --host 127.0.0.1

which returns:

Enter password: (password entered)

that returns once the password entered:

ERROR 2005 (HY000): Unknown MySQL server host 'CLOUD-SQL-PROXY-IP-ADDRESS:3306' (22)

Here are some additional information:

  • My VM (Ubuntu) is in the same region as my Cloud SQL instance, and in the same VPC network.
  • My CLoud SQL Admin API is enabled
  • The Cloud SQL instance is configured with only Private IP (Not public)
  • I have installed the MySQL client in my VM
  • The scope of the Cloud Access API's on my VM includes Cloud SQL (full access to all API's)
  • Both myself and the VM's service account has Cloud SQL Admin permissions

From docs<\/a> :

it relies on existing IP connectivity. To connect to a Cloud SQL instance using private IP, the Cloud SQL Auth proxy must be on a resource with access to the same VPC network as the instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM