Google Cloud SQL
  • 3 Minutes to read
  • Dark
    Light

Google Cloud SQL

  • Dark
    Light

Article Summary

Google Cloud SQL is a fully-managed database service. It enables users to set up, maintain, and scale relational databases such as MySQL, PostgreSQL, and SQL Server in the cloud, without the need to manage underlying infrastructure, allowing developers to focus on their applications and data rather than database management tasks.

Prerequisites

  • You have an access to Google Cloud Console with permissions to provision a SQL Storage.
  • You have configured a Google Cloud SQL instance.
  • You have configured the network access to the instance.

Authorize Connection to Google Cloud SQL

In Google Cloud Console

Create a Cloud SQL Instance

  1. In the Google Cloud Console navigate to Storage and SQL.
  2. Click on Create Instance and choose preferred SQL engine and fill in instance ID, master password, location and database version.

Configure Network Access

  1. Click on your instance and on the on the detail page, select Edit.
  2. Find the Connections section and under Public IP add all Dataddo IPs
  3. Click on Done to save the changes.

Create a Database User

  1. Select your instance and go to the Users tab.
  2. Click on Create user account and enter username and password.

In Google Cloud Shell

In order run commands on your database, you need to connect to Google Cloud Shell. This can be done by navigating to detail of your SQL instance and clicking on Open Cloud Shell.

In the Cloud Shell runn the following command to connect to the database. Make sure to replace instance, username and database with the correct values.

gcloud sql connect instance --user=username --database=database

Set User Permissions

Once you created your user and connected to Google Cloud Shell, Use SQL commands to grant the following permissions to your user:

  • CREATE,
  • SELECT,
  • UPDATE,
  • INSERT,
  • DELETE.

MySQL

Grant Dataddo the CREATE, SELECT, UPDATE, INSERT, DELETE priviledges for your database (please replace database_name with the correct value):

GRANT CREATE ON database_name.* TO 'dataddo'@'%';
GRANT INSERT, UPDATE, DELETE ON database_name.* TO 'dataddo'@'%';
FLUSH PRIVILEGES;

PostgreSQL

Grant Dataddo the SELECT, UPDATE, INSERT, DELETE priviledges for your schema (the example assumes that public schema is used):

GRANT CREATE, USAGE ON SCHEMA public TO dataddo;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO dataddo;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO dataddo;

SQL Server

Grant Dataddo the CREATE, SELECT, UPDATE, INSERT, DELETE priviledges for your database (please replace database_name with the correct value):

USE [database_name];
GO

-- Grant SELECT, INSERT, UPDATE, DELETE permissions
GRANT SELECT, INSERT, UPDATE, DELETE ON schema::dbo TO [dataddo];
GO

-- Grant CREATE TABLE permission
GRANT CREATE TABLE TO [dataddo];
GO

Create a New Google Cloud SQL

  1. On the Destinations page, click on the Create Destination button and select the destination from the list.
  2. Select your authorizer from the drop-down menu.
  3. Name your destination and click on Save.
Need to authorize another connection?

Click on Add new Account in drop-down menu during authorizer selection and follow the on-screen prompts. You can also go to the Authorizers tab and click on Add New Service.

Create a New Destination Using Supported Database Engines

After setting up the initial configuration in Google Cloud Console, continue with database engine specific configuration:

Create a Flow to Google Cloud SQL

  1. Navigate to Flows and click on Create Flow.
  2. Click on Connect Your Data to add your source(s).
  3. Click on Connect Your Data Destination to add the destination.
  4. Choose the write mode and fill in the other required information.
  5. Check the Data Preview to see if your configuration is correct.
  6. Name your flow and click on Create Flow to finish the setup.



Was this article helpful?