我创建了第二代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=redmine1@gavika-test-cloud.iam.gserviceaccount.com
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
您可以从实例详细信息页面获取实例连接名称。