Getting notAuthorized errors with cloud_sql_proxy locally

I am trying to establish a connection locally for a second generation sql server instance.

Proxy Server Call

./cloud_sql_proxy -dir=/cloudsql -instances=status-1268:us-central1:status-dev=tcp:3306 & mysql -u status_stg --host 127.0.0.1 

I don’t understand a bit how to properly configure service accounts from the API section, so I tried to use both default values, the default service account for the App Engine application and the default Compute engine service account. I also created a new service account. For each of them, I assigned the ID of the Editor and Owner service account from the Management Permissions section. Perhaps there is another way to enable the Cloud API Admin API for these accounts?

Exiting the proxy server when my service tries to talk to the database:

 ./cloud_sql_proxy -dir=/cloudsql -instances=status-1268:us-central1:status- dev=tcp:3306 & mysql -u status_stg --host 127.0.0.1 ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61) 2016/04/04 11:26:58 Open socket for "status-1268:us-central1:status-dev" at "127.0.0.1:3306" 2016/04/04 11:26:58 Socket prefix: /cloudsql 2016/04/04 11:27:10 Got a connection for "status-1268:us-central1:status-dev" 2016/04/04 11:27:11 couldn't connect to "status-1268:us-central1:status-dev": googleapi: Error 403: The client is not authorized to make this request., notAuthorized 2016/04/04 11:29:08 Got a connection for "status-1268:us-central1:status-dev" 2016/04/04 11:29:08 couldn't connect to "status-1268:us-central1:status-dev": googleapi: Error 403: The client is not authorized to make this request., notAuthorized 

Thoughts on what to look for? I think I'm missing something basic here by setting up service accounts.

(In general, for my project, I run the node.js express application and hope to connect it to the SQL instance of the 2nd level sql server without exposing it to 0.0.0.0, as I am currently working)

thanks

+7
google-app-engine google-cloud-platform google-cloud-sql
source share
3 answers

Please double check the connection string. It looks like your credentials are ok, so you probably have an error in the instance name.

I recommend copying and pasting the "Instance Connection Name" on the "Cloud Console" page for the instance:

Instance Information

+2
source share

In my case, the problem was that the service account did not have the correct role. You should at least install it in the Editor.

+3
source share

There are many reasons for this error.

following solutions:

1) Copy the instance name from the browse tab in sql. enter image description here

2) You may not have access to sql sql client .

here in more detail.

+1
source share

All Articles