MySQL Connection error Google Cloud - mysql

I deploy a node + sql application I made testes running the node app in my laptop using mysql database provided by google and the application was working fine (I needed to allow my ip address to connect) but when I deployed the application I started to receive timeout errors in my app. I solved the problem allowing any ip address to connect in my google cloud mysql instance but I not happy with this solution. Anybody can help to allow just the production node app server ip?
Thanks in advance.

If you want your API key to only be accessed from a certain IP, you can restrict it in the Developers Console.

Related

Google Cloud App Engine stopped connecting to Cloud SQL

I've got a J2EE web application deployed to Google Cloud App Engine, which connects to a MySQL DB on Cloud SQL. All of a sudden it's stopped working. The GCP URL works fine and points to the correct web UI. I've re-tested the DB connection string on Google App Engine local host server, and it works absolutely fine. Public IP is enabled on Cloud SQL and my home network IP address is authorised. But clearly the cloud app engine code isn't talking to the Cloud SQL db.
Happy to share relevant code, but not sure what code would be helpful to share, as the app engine cloud URL is working, and the DB connection string is testing fine on localhost.
Does anyone have any trouble shooting tips on how I might get to the bottom of it? Has anything changed recently with GAE/Cloud SQL?
Thanks in advance...

Access a Google Cloud VM (mysql) on Google DataStudio

Im trying to connect Google Data Studio on my Mysql database located on a Google Cloud virtual machine but im getting error. Error code: f0631df4
I have opened the mysql to accept remote connection on virtual machine and in vpc firewall.
If i try to connect through remote mysql workbench, the connection works, but not on Google Data Studio.
There's any trick to do this?
Perhaps the firewall is blocking data studio IPs from reaching the database.
Google published a list of IP ranges that you should allow in this article:
https://support.google.com/datastudio/answer/7088031?hl=en

Why I get inconsistent connection with MySQL Workbench and Google Cloud SQL?

I don't understand why I got inconsistent connection from my local MySQL Workbench to Google Cloud SQL.
Something, I can connect to my database the first time, sometimes, I need to try multiples times before getting a connection. Sadly, most of the time, it's not working.
Because I can rarely connect to the database, what kind of configuration can cause this problem?
Here's some infos:
My application hosted on Google Compute Engine don't have any connection problem.
My public IP (personnal computer) is added to the Authorised networks in my Google Cloud SQL instance. See: Enabling public IP and adding an authorized address
I have added a Firewall rules to allow port 3306 in Google Cloud VPC network
SSL is currently disable for the testing purpose
I followed these instructions: How to connect to your Cloud SQL instance database with MySQL Workbench
For the benefit of future readers, the result of the comments above was:
The problem was that the client was alternating between two possible external IP addresses. One had been authorized to access Google Cloud, and the other one had not been authorized.
Enable all client IP addresses to connect, and that should fix it.

Azure App Service - Outbound IPs Changed?

I have a site running on an Azure App Service. It connects to a MySQL DB on Google CloudSQL.
All of a sudden I am getting an error when I hit a page on my site. The error is:
Configuration Error - Reading from the stream has failed.
I know this is related to MySQL and an attempt to read from the DB.
The DB itself is fine - minimal connections, no stress.
The site runs fine from my local VS connecting to said database.
This makes me think I have hit some kind of 'outbound' connection limit on Azure. Can anyone confirm?
The Azure site is up and running but as soon as it tries to connect to the DB it falls over.
Thanks for any help you can give!
Update - IP Changed??
It appears that the App Service outbound IP addresses changed at some point yesterday so our external MySQL DB started blocking the connection attempts. Has anyone experienced this? Every single outbound IP changed. Nothing has been changed on the setup of the app (no scaling etc)

How to connect to google cloud sql instance from eclipse using App Engine?

I am trying to connect to google cloud sql instance from eclipse in my app engine connected android project.
So far i am able to connect to cloud sql instance using Class.forname("com.mysql.jdbc.Driver"). But it requires authorising my ip address in google cloud sql every time i want to use the instance hence making it unfeasible.
I know that while connecting from app engine i dont need to authorize my ip address. Bur for that i have to use GoogleDriver ie. Class.forname("com.mysql.jdbc.GoogleDriver").
But when i run my code it gives me ClassNotFoundException.
I am stuck at this situation for a long time. Please give me a proper solution to the problem
The GoogleDriver is only intended to be used when actually running on App Engine. When running from eclipse or the dev_appserver you will have to use the stock com.mysql.jdbc.Driver class, and you will have to authorize your IP address. A good example of this is shown in the documentation, which demonstrates how to choose in code which driver to use. Note the commented out line for connecting from your dev environment to Cloud SQL.
As an FYI don't forget to enable the connector for running on App Engine.
I have authorised 0.0.0.0/0 in access control in my cloud instance and now all the devices are able to connect to the cloud instance with stock mysql driver ie. com.mysql.jdbc.Driver without need to changing authorised network again and again in access control.
Still can't figure out to implement GoogleDriver but for now this solution will work.
If anyone find a more better and general way to connect to cloud instance please post your answer.