Skip to main content

CDC Sink for MySQL: Overview

Connection string​

Use a SqlConnectionString with FactoryName set to "MySqlConnector.MySqlConnectorFactory".

The legacy "MySql.Data.MySqlClient" factory name is still accepted, but the server automatically replaces it with "MySqlConnector.MySqlConnectorFactory" and raises a deprecation notification.

store.Maintenance.Send(new PutConnectionStringOperation<SqlConnectionString>(
new SqlConnectionString
{
Name = "MySqlConnection",
FactoryName = "MySqlConnector.MySqlConnectorFactory",
ConnectionString =
"Server=myserver;Port=3306;" +
"Database=mydb;User=ravendb_cdc;Password=..."
}));

Prerequisites​

MySQL/MariaDB must have binary logging enabled with row-based format:

# my.cnf / my.ini
[mysqld]
log-bin = mysql-bin
binlog_format = ROW
binlog_row_image = FULL
server-id = 1

# MySQL only: CDC Sink requires GTID.
# This is not needed for MariaDB.
enforce_gtid_consistency = ON
gtid_mode = ON

On MySQL, CDC Sink requires gtid_mode = ON.
If GTID is not already enabled, configure it before starting the CDC Sink task.
For an existing MySQL server, follow MySQL's GTID enablement procedure.

MariaDB always has GTID support enabled, so no gtid_mode setting is needed there.

The MySQL/MariaDB user in the CDC Sink connection string needs the following privileges:

GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'ravendb_cdc'@'%';
GRANT SELECT ON mydb.* TO 'ravendb_cdc'@'%';
  • REPLICATION SLAVE - required to read the binlog stream
  • REPLICATION CLIENT - required to query binlog status
  • SELECT - required for the initial full-table load

Table verification​

Verify tables in Studio, or the dry-run REST endpoint, runs the task's MySQL/MariaDB setup and initial-load steps once
against the source database before you save the task, see Verify tables.

For MySQL/MariaDB, verification is read-only.
It creates nothing on the source database, so there is nothing to clean up afterwards.

Verification checks that:

  • binlog_format is ROW
  • binlog_row_image is FULL
  • gtid_mode is ON (MySQL only)
  • Each configured table and its mapped columns exist, and the user can read the table
    (it reads at most one row from each)

Verification does not open the binlog stream, so a successful verification does not confirm that:

  • Binary logging is enabled (log-bin)
  • The user has the REPLICATION SLAVE and REPLICATION CLIENT privileges

Streaming behavior​

After the initial load, MySQL/MariaDB CDC Sink reads row-based binlog events continuously.
It does not poll the source database for changes, so the CdcSink.SqlServer.PollIntervalInSec server configuration setting applies only to SQL Server CDC Sink tasks and has no effect on MySQL/MariaDB.

Task configuration​

Most CDC Sink task configuration is shared across supported source database engines.
See Configuration Reference for full details, including table mappings, delete behavior, and patches.

When SourceTableSchema is omitted, MySQL/MariaDB uses the database name from the connection string as the default schema.

In this article