---
title: "CDC Sink for MySQL: Overview"
description: "CDC Sink support for MySQL and MariaDB - using binlog replication to stream changes into RavenDB in real time."
url: "https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/source-database-setup/mysql/overview"
version: "7.2"
language: "csharp"
---

# CDC Sink for MySQL: Overview

> Client language: C#.
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - CDC Sink supports MySQL and MariaDB as source databases using
>   [binary log (binlog) replication](https://dev.mysql.com/doc/refman/8.0/en/replication.html).
>
> - MySQL and MariaDB record row-level changes in the binlog.  
>   The CDC Sink task reads the binlog stream continuously and processes INSERT, UPDATE, and DELETE events according to the task configuration.
>
> - In this article:
>   - [Connection string](#connection-string)
>   - [Prerequisites](#prerequisites)
>   - [Table verification](#table-verification)
>   - [Streaming behavior](#streaming-behavior)
>   - [Task configuration](#task-configuration)

## Connection string {#connection-string}

Use a [SqlConnectionString](https://docs.ravendb.net/7.2/server/ongoing-tasks/etl/sql.md#add-an-sql-connection-string) 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.

### Sync

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

### Async

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

## Prerequisites {#prerequisites}

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

```ini
# 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
```

> **Note**
>
> 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:

```sql
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 {#table-verification}

**Verify tables** in Studio, or the [dry-run REST endpoint](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/manage-cdc-sink-tasks/create-task.md#verify-the-configuration), runs the task's MySQL/MariaDB setup and initial-load steps once  
against the source database before you save the task,
see [Verify tables](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/manage-cdc-sink-tasks/create-task.md#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 {#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 {#task-configuration}

Most CDC Sink task configuration is shared across supported source database engines.  
See [Configuration Reference](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/manage-cdc-sink-tasks/configuration-reference.md)
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.

## See also

- [CDC Sink Overview](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/overview.md)
- [Configuration Reference](https://docs.ravendb.net/7.2/server/ongoing-tasks/cdc-sink/manage-cdc-sink-tasks/configuration-reference.md)
