简体   繁体   中英

GCE SQL proxy connecting to wrong sql ip

I am having a strange issue with my GCE Proxy. I used to have a docker image with an application that would use the GCE proxy to connect to the mysql database(second generation). Everything worked fine, but I had to stop the services for like a month.

Now I need them back up and for some reason I am not able to connect to the dabase(configuration did not basically chang, and I am using the same docker image with the code)

On closer inspection I see in logs:

Caused by: java.sql.SQLException: Access denied for user 'my-usr'@'cloudsqlproxy~SOME_IP' (using password: YES)

The problem is, that the "SOME_IP" is not actually the sql instance IP and I have no idea from where that IP is coming from.

Does anyone have an idea on how to fix this issue?

I did try to:
-recreate the database user
-recreate the service account

Any advice is welcomed

You can use Cloud SQL proxy to connect your mysql instance, see the step by step below:

  1. Download the proxy:

    wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy

  2. Make the proxy executable:

    chmod +x cloud_sql_proxy

  3. Using the proxy to connect to multiple instances

    ./cloud_sql_proxy -instances=yourProject:us-central1:myInstance=tcp:3306,yourProject:us-central1:myInstance2=tcp:3307 & mysql -u myUser --host 127.0.0.1 --port 3307

  4. Try to connect your database

    mysql -h127.0.0.1 -u$YOUR_CLOUD_SQL_USER -p$YOUR_CLOUD_SQL_PASSWORD

Hoping it helps you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM