jdbc connection errors from Google Script - mysql

Anyone out there who could help me? I have been bashed over two straight days by failed connection requests from an Google Apps Script to a mysql db hosted on Dreamhost. Have had extensive support from Dreamhost but no solution. Have concluded the failure to connect is the same issue confronted by many in existing threads.
All I want to do is collect internal business data in Google sheets and load into a tables in my cloud sql db. Problems could be attributable to either a bug or an IAM permissions issue. My account is owner of the GSuite orgaqnization, and I also granted it explicit role for Cloud SQL Client. In connection requests, I've tried using both host URL and the host IP to connect. Neither worked and I am frustrated. Any ideas?
var conn = Jdbc.getConnection('jdbc:mysql://mysql.url.com:3306/db_name','user','password')
Thanks in advance for any help or recommendations. CW

Related

Google App Script (not) using GCP Classic VPN route?

This reads like a duplicate of other GAS+VPN/SDC questions but none of the existing questions refer explicitly to using a GCP Hybrid (Classic) VPN to provide App Script access to on-premise resources.
I have the GCP VPN setup and working (verified pinging both ways via VM) and I have associated the App Script project with the GCP resource but the App Script cannot URLFetch from anywhere over the VPN. Is this a known limitation of App Script or can someone point me in the right direction please?
edit 1: I have also tried to setup a Serverless VPC Connector but as App Script has no VM instance, I couldn't complete the Connector setup. Giving network.user access to the App Script's GCP service accounts didn't achieve anything.
edit 2:
#eric-wong wrote the following in an answer to a smiliar question 2 years ago:
The documentation made it quite clear, that since App Scripts are ran on shared App Engine instances, it is impossible to restrict with IP, and that also implies the networking capability would be very limited (i.e. no VPC peering or alike)
I cannot understand why Google would provide the ability to link an App Script to a GCP project but then not provide a mechanism to utilise the GCP's network.
I originally asked this question on ServerFault as I thought I had a GCP config issue but now I'm feeling like it's more like a GAS issue.
Thanks for all help!

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.

MySQL Connection error Google Cloud

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.

ERROR 2003 (HY000): Can't connect to MySQL server on 'x.x.x.x' (110)

I'm trying to establish a basic mysql connection from a google compute engine instance in one project to a google cloud sql instance (2nd generation) in a different project.
I've done this many times before without any problem. You simply add the ip address of the google compute instance to the list of authorized networks for the google cloud sql instance. This has always worked in the past but it is not working now.
The only thing that I can think of which is different about this situation is that I've recently been experimenting with using the cloudsql-proxy to establish a connection from a different gce instance to the same google cloud sql instance. Could this be the problem? Perhaps the google cloud sql instance is getting confused by having to support both connection mechanisms?
I just need the connection to work. Is there a work-around?
There isn't a problem using both modes of connectivity simultaneously.
The only thing I can think of is that you are accidentally using an ephemeral IP addresses for your VMs instead of static, which means the VM may have a different IP address than you expect (after a restart, for example).
If that's not the case, please send a mail to cloud-sql#google.com with a little bit more information (project and database name, project/name/ip of your VM) so that we can figure out what's going on in the backend.

Cannot access Google Cloud SQL database from my App Engine

Last week I tried to setup Google Cloud for a NodeJS API and Cloud SQL database. Overall it works fine, but I can't access my Cloud SQL database. The authorization of the SQL database shows that all apps within the current project are granted to access the database. Unfortunality, this is not true. I need to granted the IP addresses of the instances from the App Engine. The IP adressess of the instances constantly changes after I deploy a newer version of the the API.
Does anybody have a solution to get access from the App Engine to the Cloud SQL database. It's very annoying to add constant the instance ip address to grant the database.
Sample here
Thank you in advance!
Jelle
I was going to suggest to assign a static IP to the app engine, but seems like it's not possible in App engine (it's possible in compute engine though). So lets tackle the root of the problem, you being unable to access cloud sql from App engine, are you sure you followed the instructions of the following link to the letter?
https://cloud.google.com/nodejs/getting-started/using-cloud-sql
This might solve your connection issue if you haven't.