ahmetb / cloud-run-faq

Unofficial FAQ and everything you've been wondering about Google Cloud Run.
https://cloud.run
Creative Commons Attribution 4.0 International
2.32k stars 124 forks source link

Connecting to a external MySql instance #128

Closed do-web closed 3 years ago

do-web commented 3 years ago

Thanks for your nice faq, do you now how i can connect to a self hosted MySql instance that is not in the Google Cloud?

If i try to connect the ip is always replaced with a google ip and i cant connect to my mysql server.

My connection:

DATABASE_URL="mysql://root:test@202.x.x.x:3306/my_db?serverVersion=8.0"

Then if try to deploy it says:

SQLSTATE[HY000] [1045] Access denied for user 'root'@'35.x.x.x' (using password: YES)

It looks like this IP 35.x.x.x is a google cloud IP, but where does this IP come from??? And when I deploy again there is another google IP.

ahmetb commented 3 years ago

Either you give access to all IPs or you use this to fix egress IP of your Cloud Run app to a particular static IP. https://cloud.google.com/run/docs/configuring/static-outbound-ip