About
Article about the connection to a MySQL GCP (Google Cloud Platform) database with:
- the IP configuration (Private or Public access)
- and a connection (Dbeaver (A jdbc client) and mysql cli)
Steps
Create your database and get your public IP
Add IP authorization
for a private network
For a private network for instance your home …
- Go to a website that will show your public IP. Example https://whatsmyip.com
- Go to the connection tab of the SQL instance and add the following authorization network
where the network id is given with the CIDR notation where:
- 143.176.206.82 is your public IP (that we got in the step above)
- /32 is the routing prefix and means that there is only one host on this network.
for a public network
For a public network, if you want to authorize any server in case of faas solution or in paas, just add the entire world with the following CIDR 0.0.0.0/0.
Add SSL
The traffic will go through public network, you need therefore to use SSL in order to encrypt the traffic and before all the login/password.
Create a Client Certificate:
You got three files:
- Server Certificate
- Client Certificate
- Client Private Key
Put the private key in a secure place.
Connection
Dbeaver
- With DBeaver, create a MySQL connection and set the following connection properties:
- public ip of the GCP database in the server host
- root password that you gave during the database creation
- Add the SSL parameters
- Check that you can connect and see the schemas.
MySQL Cli
For a connection with the mysql cli, see MySQL - SSL connection