简体   繁体   中英

Can't connect to Google Cloud SQL from Google Compute Engine with Cloud SQL Proxy

I'm trying to connect a GCE instance to a Cloud SQL instance (2nd gen) with Cloud SQL Proxy. When i ssh to the GCE instance and

sudo ./cloud_sql_proxy -dir=/cloudsql

I get

2016/07/13 18:59:28 Using gcloud's active project: xxxx-0000
2016/07/13 18:59:29 Error listing instances in xxxx-0000:
    googleapi: Error 403: Access Not Configured.
    Cloud SQL Administration API has not been used in project 000000000000
    before or it is disabled. Enable it by visiting
    https://console.developers.google.com/apis/api/sqladmin/overview?project=000000000000
    then retry.
    If you enabled this API recently, wait a few minutes for the action to
    propagate to our systems and retry., accessNotConfigured
2016/07/13 18:59:29 no Cloud SQL Instances found in these projects: [xxxx-0000]

I have followed the documentations at
https://cloud.google.com/sql/docs/compute-engine-access#gce-connect-proxy and
https://cloud.google.com/sql/docs/sql-proxy

Both instances are within the same project and Cloud SQL API is enabled on the GCE instance (plus the default ones.) By my understanding, the default GCE service account should be able to authenticate the proxy.

Using cloud_sql_proxy with -instances seems to work but errors with accessNotConfigured too while trying to connect.

As per the error message, you need make sure that the "Cloud SQL Admin" API is enabled by visiting the provided link.

There's also a GUI way to connect your Compute Engine instance if you're using a 2nd gen GCloud SQL instance. You first get the external IP of your compute engine and include it in the Authorizations tab of your GCloud SQL dashboard. Here's a quick video

Enabling Cloud SQL Admin API will solve your problem:

在此处输入图像描述

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