MySql - Google Cloud Platform Database Creation and Connection

> Database > MySQL

1 - About

Article about the connection to a MySQL GCP (Google Cloud Platform) database with:

2 - Steps

2.1 - Create your database and get your public IP

  • Go to the GCP SQL Console, create your database and save the root password.
  • After the creation, you can see the public IP of the database.


2.2 - Add IP authorization

2.2.1 - for a private network

For a private network for instance your home …

  • 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:

2.2.2 - 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

2.3 - 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.


2.4 - Connection

2.4.1 - 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.

2.4.2 - MySQL Cli

For a connection with the mysql cli, see MySQL - SSL connection