Using Google Cloud SQL with App Engine
I explore using Google Cloud SQL.
Create DB
Visit SQL section.
Select MYSQL.
Enabling Compute Engine API.
I selecting MySQL 8.0 region same as App Engine region. This is test DB, thefore setting lowest instance resources.
New project MySQL instance created.
Creating test_database
database
Connect to the DB
Connect to the db via DBeaver. By default, all external IP addresses are blocked from reaching your Cloud SQL instance.
Add your IP to Authorized networks.
Let’s test DB connection.
By default, Cloud SQL allows unencrypted connections from authorized networks. This is not good, as it allows traffic to be intercepted, possibly leading to a data breach.
Recommend you use the Cloud SQL SQL proxy to connect DBeaver to Cloud SQL.
Install SQL proxy on linux 64bit:
|
|
In order to run the proxy we need to get the instance name from the developer console. Go to the Cloud SQL instance page and click the instance name to open its Instance details page.
Start the proxy in its own terminal so you can monitor its output. Replace <INSTANCE_CONNECTION_NAME> with the instance connection name you copied in the previous step. Replace .
|
|
Testm Cloud SQL proxy connection.
Then you can click the Test Connection button and you should see.
Conncection via Cloud SQL Proxy successfull.
Now I can enable Allow only SSL connections
and restart service.
As expected, unsecure conection is failing, althougt connection via proxy work fine.