MySQL

This page describes how to create and maintain connections to your MySQL database.

Before you can write your transformed data to a table in MySQL, you should first establish a connection to your MySQL database.

Supported versions

MySQL database versions 5.6, 5.7, and 8.0 are supported. This includes managed database instances hosted by AWS RDS.

Create a MySQL connection

Simple example

A MySQL connection can be created as simply as follows:

CREATE MYSQL CONNECTION mysql_connection
    CONNECTION_STRING = 'jdbc:mysql://demo.c4q3plwekwnv.us-east-1.rds.amazonaws.com:3306/demo'
    USER_NAME = 'your username'
    PASSWORD = 'your password'

Note that a MySQL connection must specify the database it is connecting to within the connection string.

This means that in order to connect to multiple databases within your account, you need to create at least one connection per database.

Full example

The following example also creates a MySQL connection but additionally limits the maximum number of concurrent connections to your database by configuring an additional option MAX_CONCURRENT_CONNECTIONS:

CREATE MYSQL CONNECTION mysql_connection
    CONNECTION_STRING = 'jdbc:mysql://demo.c4q3plwekwnv.us-east-1.rds.amazonaws.com:3306/demo'
    USER_NAME = 'your username'
    PASSWORD = 'your password'
    COMMENT = 'New MySQL connection';

For the full list of connection options with syntax and detailed descriptions, see MySQL connection with SQL.

Once you've created your connection, you are ready to move on to the next step of building your data pipeline: reading your data into SQLake with an ingestion job.

Alter a MySQL connection

Certain connection options are considered mutable, meaning that in some cases, you can run a SQL command to alter an existing CDC connection rather than create a new one.

To change the database you are connecting to but keep everything else the same without having to create an entirely new connection, you can run the following command:

ALTER MYSQL CONNECTION my_mysql_connection
    SET CONNECTION_STRING = 'jdbc:mysql://mysql-cluster-1.cnpkgni9k2tq.us-east-1.rds.amazonaws.com'

To check which specific connection options are mutable, see: MySQL connection with SQL

Drop a CDC connection

If you no longer need a certain connection, you can easily drop it with the following SQL command:

DROP CONNECTION my_mysql_connection; 

However, note that if there are existing tables or jobs that are dependent upon the connection in question, the connection cannot be deleted.

For more details, see: DROP CONNECTION

Last updated