2016-12-15 117 views
0

我已經按照指令:https://cloud.google.com/sql/docs/external從外部應用程序連接到谷歌雲SQL

STEP1. $ chmod +x ~/GCP/cloud_sql_proxy 

STEP2. $ gcloud auth application-default login 

STEP3. $ ./cloud_sql_proxy -instances=[INSTANCE_CONNECTION_NAME]=tcp:3306 -credential_file=[PATH_TO_KEY_FILE] 

2016/12/15 19:55:44 Ready for new connections

STEP4. $ mysql -u root -h 127.0.0.1 -p 

但我得到了在碼頭下面的錯誤;

2016/12/15 23:51:20 New connection for "[INSTANCE_CONNECTION_NAME]" 
2016/12/15 23:51:20 Thottling refreshCfg([INSTANCE_CONNECTION_NAME]): it was only 
called 23.918136971s ago 
2016/12/15 22:08:26 couldn't connect to "[INSTANCE_CONNECTION_NAME]": 
Post https://www.googleapis.com/sql/v1beta4/projects/{PROJECT_ID]/ 
instances/[INSTANCE_NAME]/createEphemeral?alt=json: private key should be a PEM or 
plain PKSC1 or PKCS8; parse error: asn1: syntax error: sequence truncated 
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial 
communication packet', system error: 0 

我被困在這裏。 感謝您的幫助。

+0

憑證文件來自哪裏?您是否創建了一個編輯角色的服務帳戶並下載私鑰?根據https://cloud.google.com/sql/docs/sql-proxy#create-service-account。 – jarmod

+0

@jarmod我從STEP#2獲得了憑證文件。 保存到文件的憑證[/Users/******/.config/gcloud/application_default_credentials.json] 這些憑證將被請求 應用程序默認憑證的任何庫使用。 – Danny

+0

@jarmod它與創建服務帳戶一起工作。謝謝。 – Danny

回答

相關問題