Search code examples
google-app-enginegoogle-cloud-sql

Connecting to Google Cloud SQL from External Applications


I've followed the instruction: https://cloud.google.com/sql/docs/external

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]

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

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

But I got the following error in the Terminal;

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

I am stuck here. Appreciate for all your help.


Solution

  • Did you create a service account with Editor role and download the private key?