我正在尝试通过 MySQL 客户端连接到 Google Cloud SQL 实例,这需要我通过 Google Cloud 代理进行连接。我已按照 Google Cloud Docs 上的所有说明进行操作,但在运行命令启动代理后(使用正确的 INSTANCE_CONNECTION_NAME
和 PATH_TO_KEY_FILE
),我收到以下 error
.
命令 :
./cloud_sql_proxy -dir=/cloudsql -instances=INSTANCE_CONNECTION_NAME \ - credential_file=PATH_TO_KEY_FILE &
错误 :
couldn't connect to "INSTANCE_CONNECTION_NAME": ensure that the account has access to "INSTANCE_CONNECTION_NAME" (and make sure there's no typo in that name). Error during createEphemeral for INSTANCE_CONNECTION_NAME: googleapi: Error 403: Access Not Configured. Cloud SQL Administration API has not been used in project 563584335869 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/sqladmin.googleapis.com/overview?project=563584335869 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry., accessNotConfigured
我已经确认在项目的控制台上启用了 Google Cloud SQL API,但奇怪的是我的项目名称不是 563584335869,而且我已经通过 GC CLI 设置了正确的项目名称,但无济于事。所以访问时https://console.developers.google.com/apis/api/sqladmin.googleapis.com/overview?project=563584335869 , 我懂了:
The API "sqladmin.googleapis.com" doesn't exist or you don't have permission to access it
我还在角色 Cloud SQL Client 下创建了一个服务帐户,并下载了 PATH_TO_KEY_FILE 指向的私钥。
最佳答案
您能否确认您启用了“Cloud SQL API”(sqladmin.googleapis.com)而不是“Cloud SQL”API? (sql-component.googleapis.com)?
您能否提供更多有关您的环境的信息?您是在本地机器上运行它还是在 Cloud Shell 中工作?
关于google-cloud-platform - Google Cloud SQL 连接错误 - 403 : Access Not Configured - despite having enabled the API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51235151/