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
- Log into the Google Cloud Console
- Navigate to SQL
- Select your 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.
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
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
- 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
Configure Network Settings:
- Go to your Cloud SQL instance settings
- Navigate to the "NETWORKING" tab
Configure IP Assignment:
- Under "Instance IP assignment"
- Verify that "Public IP" is enabled and selected
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
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
- Select MySQL as database type
- 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
- Select PostgreSQL as database type
- 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:
In your Cloud SQL instance settings:
- Navigate to the instance configuration
- Enable SSL connections
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.