我创建了第二代MySQL SQL实例。我在计算云上创建了一个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
您可以从实例详细信息页面获得实例连接名称。
我也有同样的问题,我的解决方案是
./cloud_sql_proxy -instances=cloud-test-XXXXXXXXXXXXX:europe-west3:test-mysql=tcp:3306
而不是
./cloud_sql_proxy -instances=test-mysql=tcp:3306
我在文档中发现的内容:/