Skip to content

Google Cloud SQL Connection Guide

Overview

This guide covers how to configure and connect to Google Cloud SQL databases in DBConvert Streams.

Setting Up Cloud SQL Instance

  1. Log into the Google Cloud Console
  2. Navigate to SQL
  3. Select your MySQL/PostgreSQL instance

select MySQL/ PostgreSQL instance

PostgreSQL Change Data Capture (CDC) Configuration

If you plan to use Change Data Capture (CDC) mode with PostgreSQL, you'll need to configure both logical replication and user permissions. These steps are specific to PostgreSQL and can be skipped for other database types.

Google Cloud SQL PostgreSQL Flags

  1. Enable logical replication:

    • Navigate to your Cloud SQL instance in Google Cloud Console
    • Click the "Edit" button
    • Expand the "Customize your instance" section
    • Locate the "Flags" settings
    • Add the following database flag: cloudsql.logical_decoding = on
    • Save your changes and wait for the instance to update
  2. Configure user permissions:

    Connect to your database using a PostgreSQL client and execute one of the following options:

    Option 1: Create a new dedicated user (Recommended)

    sql
    -- Create a new user specifically for replication
    CREATE USER replication_user WITH PASSWORD 'your_password';
    ALTER USER replication_user WITH REPLICATION;
    GRANT SELECT ON ALL TABLES IN SCHEMA public TO replication_user;
    ALTER DEFAULT PRIVILEGES IN SCHEMA public 
        GRANT SELECT ON TABLES TO replication_user;

    Option 2: Modify an existing user

    sql
    -- Add replication privileges to an existing user
    ALTER USER existing_user WITH REPLICATION;
    GRANT SELECT ON ALL TABLES IN SCHEMA public TO existing_user;
    ALTER DEFAULT PRIVILEGES IN SCHEMA public 
        GRANT SELECT ON TABLES TO existing_user;

    INFO

    Replace 'your_password' and 'existing_user' with your actual values. The REPLICATION privilege is required for CDC operations, while SELECT privileges are needed to read the table data.

Network Configuration

  1. Obtain Public IP Address:
    • Navigate to your Cloud SQL instance's "SUMMARY" tab
    • Locate the Public IP address - you'll need this for establishing connections

Public IP Address

  1. Configure Network Settings:

    • Go to your Cloud SQL instance settings
    • Navigate to the "NETWORKING" tab
  2. Configure IP Assignment:

    • Under "Instance IP assignment"
    • Verify that "Public IP" is enabled and selected
  3. Set Up Authorized Networks:

    • Locate the "Authorized networks" section
    • Click "ADD A NETWORK"
    • Enter the following details:
      • Network name: Provide a descriptive name (e.g., "dbconvert-streams")
      • IP address: Enter your DBConvert Streams server IP
      • Format: Use CIDR notation with /32 suffix for single IP Example: 159.69.81.186/32

Authorize Network

Connection Configuration

Important

When configuring connections to Cloud SQL, always use the instance's Public IP address as the server address. Do not use the instance connection name (e.g., project:region:instance), as this format only works with Cloud SQL Proxy.

For MySQL Connections

  1. Select MySQL as database type
  2. Enter connection details:
    • Server: Use the Public IP address of your instance
    • Port: 3306
    • User ID: Your database username
    • Password: Your database password
    • Database: Your database name

For PostgreSQL Connections

  1. Select PostgreSQL as database type
  2. Enter connection details:
    • Server: Use the Public IP address of your instance
    • Port: 5432
    • User ID: Your database username
    • Password: Your database password
    • Database: Your database name
    • Schema: Your schema name (default: public)

SSL Configuration

By default, Google Cloud SQL allows unencrypted connections (not recommended for production). If you want to enable SSL:

  1. In your Cloud SQL instance settings:

    • Navigate to the instance configuration
    • Enable SSL connections
  2. Configure SSL in DBConvert Streams:

    • Enable SSL mode
    • Upload the SSL certificate
    • Select appropriate SSL mode

WARNING

Using unencrypted connections is not recommended for production environments.

DBConvert Streams - event driven replication for databases