无法通过Cloud SQL Proxy连接到MySQL

问题描述 投票:4回答:1

我创建了第二代MySQL SQL实例。我在Compute Cloud上创建了一个VM。我按照说明操作并通过以下方式启动SQL代理:

./cloud_sql_proxy -instances=redmine=tcp:3306 -credential_file=/home/sudheer/redmine1.json
2017/12/21 05:43:00 using credential file for authentication; [email protected]
2017/12/21 05:43:00 Listening on 127.0.0.1:3306 for redmine
2017/12/21 05:43:00 Ready for new connections

如您所见,代理已启动并准备好侦听连接。从另一个终端,我试图连接到代理,我收到此消息:

mysql -u root --host=127.0.0.1 -p
Enter password:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

在代理方面,我看到这条消息:

2017/12/21 05:43:34 New connection for "redmine"
2017/12/21 05:43:35 couldn't connect to "redmine": ensure that the account has access to "redmine" (and make sure there's no typo in that name). Error during createEphemeral for redmine: googleapi: got HTTP response code 404 with body: Not Found

我不确定缺少什么。我向IAM成员提供了项目编辑器和SQL客户端角色。

更新:我自己找到了解决方案。 INSTANCE_CONNECTION_NAME不正确。它的格式是:

project_name:region:instance_name

您可以从实例详细信息页面获取实例连接名称。

google-cloud-platform google-compute-engine google-cloud-sql cloud-sql-proxy
1个回答
2
投票

我有同样的问题,我的解决方案是

./cloud_sql_proxy -instances=cloud-test-XXXXXXXXXXXXX:europe-west3:test-mysql=tcp:3306

代替

./cloud_sql_proxy -instances=test-mysql=tcp:3306

我在文档中找到的内容:/

© www.soinside.com 2019 - 2024. All rights reserved.