Private Cloud SQL on phpMyAdmin (AppEngine) - google-app-engine

I've followed the following tutorial step by step.
I've tried the following:
Installing the App Engine phpMyAdmin on the same project as my Cloud SQL server.
Installing it a different project and adding the right IAM roles (Cloud SQL Admin)
I can't for the life of me get it to connect. I get the following error:

It's unclear how you are trying to connect based on the info you have provided. To connect on App Engine, you need to use the provided unix domain socket at /cloudsql/<INSTANCE_CONNECTION_NAME> (the instance connection name can be found on your instances details page, and is in the format <project>:<region>:<instance>).
For more details on connecting from App Engine, check out the Connecting from App Engine page.

Related

Cloud SQL / MySQL server fails after deploying to Google Cloud

I have a Google App Engine application that operates perfectly when run locally using localhost:8080, but after I deploy to the cloud using gcloud app deploy, I receive the following error:
Warning: PDO::__construct(): MySQL server has gone away in /base/data/home/apps/s~fileabcd/20190320t221240.123456737151234567/gac_abcd.php on line 7
Warning: PDO::__construct(): Error while reading greeting packet. PID=-1 in /base/data/home/apps/s~fileabcd/20190320t221240.123456737151234567/gac_abcd.php on line 7
Any ideas why this is happening?
I discovered the reason why my Google App Engine (GAE) application functioned properly on localhost, but threw a MySQL server has gone away error after being deployed to [PROJECT-ID].appspot.com.
The reason is because my application was connecting to a Cloud SQL instance in a different project, and in order to do this you must grant the default appengine service account ([PROJECT-ID]#appspot.gserviceaccount.com) one of the following IAM roles:
Cloud SQL Client
Cloud SQL Editor
Cloud SQL Admin
After I added the App Engine default service account as a Cloud SQL Client Role in the project containing the Cloud SQL instance, everything worked perfectly.
From the Cloud SQL documentation.

Cannot connect to cloud SQL [SQLSTATE[HY000] [2002] No such file or directory]

I have set up 2 projects in my Google Cloud console. The following are the two projects that I have set up in my console.
1. Cloud SQL + App Engine
2. App Engine (New)
So the idea is App Engine (1) is running the same database as App Engine (2). I have already set up the IAM Permission Page and IAM Admin and Project Page.
I have given both projects as Project Editor role too, but still my (2) still can't connect to my (1) database.
Any help please?
Granting access to an application does not automatically enable a database user account to connect to the instance.
You may connect through a proxy, in which case you should follow these steps:
Enable the API
Install the proxy client on your local machine
Determine how you will authenticate the proxy
If required by your authentication method, create a service account
Determine how you will specify your instances for the proxy
Start the proxy
Update your application to connect to Cloud SQL using the proxy
You can find related details on the Connecting to Cloud SQL from External Applications.
This documents provides steps that cover configuring access for IP connections as well.
If you connect from within the app engine environment, you may have a look at Connecting from App Engine.

Communications link failure when connect to Google Cloud SQL(second gen) only from prod

Setting up a google cloud platform app with google cloud sql and for the life of me I cannot get a connection to the db when I run the code from google servers.
Following this example: https://cloud.google.com/appengine/docs/java/cloud-sql/?csw=1
I've gotten the non production url constructed properly and can connect with no issues to the cloud sql with this url
Class.forName("com.mysql.jdbc.Driver");
url = "jdbc:mysql://<ip-address>:3306/<database>?user=root";
So that's all good. This is the url I'm building for the prod connection.
Class.forName("com.mysql.jdbc.GoogleDriver");
url = "jdbc:google:mysql://<project-id>:<cloud sql instance name>/<database>?user=root";
I got the Project ID from the dashboard and the Instance ID SQL Instances List, database is the same as the non prod value and since non prod works I'm confident that's alright
Product and Instance ID locations I pulled them from
After deploying it all out I get the error message:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
appengine-web.xml does have use-google-connector-j set to true and I saw that for the second generation cloud sql you do not need to specify your app on the authorization list in cloud SQL.
Any help would be appreciated
https://cloud.google.com/sql/docs/dev-access#gaev1-csqlv2-connect
You should look at "instance connection name" in "Instance details" of your instance. For second generation, it's "project-id:region-name:cloud-sql-instance-name", not "project-id:cloud-sql-instance-name" as in the first generation.
When trying to connect to GCP SQL from google cloud run, do not forget to enable connection to GCP SQL from the google cloud run service level settings.
Having the setting disabled (default) can also cause the communications link faulure error.

Unable to connect to Cloud SQL from Google App Engine database

I am unable to connect to Cloud SQL from Google App Engine. I am not sure what the problem is but I came across a note from an instruction stating this is a performance Cloud SQL in alpha stage and connection from Google App Engine are not excepted. Is this the problem I am unable to connect to Cloud SQL? Can anyone explain me the the note? The screenshot of the note is below
Connecting from App Engine is not yet supported for Second Generation instances. You will need to create a First Generation instance if you must connect from App Engine.

Google Cloud SQL configuration - get OAuth 2 token via GoogleCL for SQL or Eclipse

Configuring Google Cloud SQL to work with an app built using GWT Eclipse EE Plugin and am having authentication issues.
Google Command Line Tool - try running ./google_sql.sh instance
Need guidance setting up GoogleCL for CloudSQL. I installed regular GoogleCL using MacPorts. What next? I tried:
echo 'export PATH=Applications/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.0/appengine-java-sdk-1.7.0/bin/:$PATH' >> ~/.profile
ECLIPSE
Eclipse asks for Instance Name and Database name in two separate fields. I've tried every permutation of Project ID:database name (e.g. petproject:dog).
Here is the Eclipse error report (its the same every time):
Could not connect to Profile (name-of-the-project-in-Eclipse.GoogleCloudSQL.DevInstance).
Error creating SQL Model Connection connection to Profile (name-of-the-project-in-Eclipse.GoogleCloudSQL.DevInstance). (Error: Access denied for user 'my-login-id'#'localhost' (using password: YES))
Access denied for user 'my-login-id'#'localhost' (using password: YES)
Error creating Google Cloud SQL Connection factory connection to Profile (pse:
Could not connect to Profile (name-of-the-project-in-Eclipse.GoogleCloudSQL.DevInstance). (Error: Access denied for user 'my-login-id'#'localhost' (using password: YES))
Other
I can get a test app to work just fine. I have the test app running through a domain that I own. I've created a Google Cloud SQL project and instance. I've given permission for my app to use the instance on the Google API console. I have local mysql running and created the database/schema on my machine. I can't link up my local database to the GWT because the entire Google Cloud SQL needs to function.
Thanks -- very much appreciated.

Resources