MySQL and MariaDB Connectors

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Many legacy systems that are now being replaced run on MySQL or MariaDB: an e-commerce shop from the 2000s, an in-house CRM, a PHP application whose database has outlived three rewrites of its front end. Debezium reads both databases the same way, from the binary log (binlog) that they already write for replication, and turns every committed row change into an event. MariaDB has its own connector, which shares most of its code and configuration with the MySQL connector but differs in the details that matter during setup.

This page uses a generic legacy MySQL database, shop, with a customer table and an orders table, as the source of a migration. It explains how the connectors read the binlog, how to prepare the server and the user, why the schema history topic exists and how to protect it, how snapshots lock the legacy database, how to move the binlog position with a signal, which legacy data types need converters, and what is different for MariaDB. It assumes you know the change event format (Anatomy of a Change Event) and Kafka Connect (Kafka Connect). The Bookshop example in the rest of this section uses an Oracle legacy database; its connector is on Oracle Connector.

Checked on 2026-11-09 against Debezium 3.7.1.Final and Apache Kafka 4.3.1 (the Kafka version inside the quay.io/debezium/connect:3.7.1.Final image). According to the Debezium 3.7 release overview, Debezium 3.7 is tested against MySQL 8.0.x, 8.4.x and 9.7 (MySQL Connector/J 26.10.0) and against MariaDB 11.4.x, 11.8.x and 12.3 (MariaDB Connector/J 3.5.3). The Docker lab on this page (MySQL 8.4 and MariaDB 11.8 servers, the shop schema, the connector user, and the shop-mysql-source and shop-mariadb-source connectors with the TINYINT(1) converter) was run on 2026-11-09, and the sample events are trimmed copies of that run. The set-binlog-position signal, the zero-date and JDBC-sink converters, the InnoDB-based binlog and the Amazon RDS settings are derived from the official documentation and were not run.

How the binlog connectors work

MySQL and MariaDB write every committed transaction to the binlog, in commit order. Replicas read the binlog to stay in sync; Debezium pretends to be one more replica. It connects with the replication protocol, identifies itself with a numeric server ID (database.server.id), and receives the binlog events. With binlog_format=ROW, each event contains the changed rows, and with binlog_row_image=FULL, it contains every column of each row before and after the change.

flowchart LR APP[Legacy shop application] -->|INSERT, UPDATE, DELETE, DDL| DB[(MySQL or MariaDB)] DB --> BL[Binlog files: row events and DDL statements] BL -->|replication protocol, server ID 184054| DBZ[Debezium MySQL or MariaDB connector] DBZ -->|row change events| T[Topics legacy-shop.shop.customer, legacy-shop.shop.orders] DBZ -->|DDL with binlog position| SH[Schema history topic legacy-shop.schema-history] DBZ -->|DDL for consumers| SC[Schema change topic legacy-shop] DBZ -->|binlog file, position, GTID set| OFF[Kafka Connect offsets]

Three things distinguish the binlog connectors from the PostgreSQL connector:

  • The server does not keep the position for you. There is no replication slot. The connector stores its binlog file name, position and (with GTIDs) the GTID set in the Kafka Connect offsets. The server deletes old binlog files on its own schedule. If the connector is stopped longer than the binlog retention, its position is gone, and it needs a new snapshot.

  • Row events do not describe the table. A binlog row event contains column values, not column names or types. The connector rebuilds each table’s structure by parsing the DDL statements that also appear in the binlog, and stores every DDL statement, with its binlog position, in the schema history topic. Losing that topic is an outage.

  • The snapshot needs locks. To read a consistent copy of the tables and the exact binlog position that matches it, the connector briefly takes a global read lock or table locks on the legacy database.

The connector’s topics are named topicPrefix.databaseName.tableName, so with topic.prefix=legacy-shop the shop database produces legacy-shop.shop.customer and legacy-shop.shop.orders. The connector uses a single task.

Supported topologies

The official documentation lists these topologies:

Topology What it means for the connector

Standalone

The binlog must be enabled. The connector always follows this one server.

Primary and replica

The connector can follow the primary or a replica that has its binlog enabled. Binlog positions differ from server to server, so it must follow one server. Reading from a replica keeps the snapshot load and the binlog connection off the legacy primary.

Highly available clusters

With GTIDs, a replica sees all transactions from any primary, so the connector can move to another server and find its position by GTID.

Multi-primary (NDB cluster replication)

Requires GTIDs. The connector can fail over between multi-primary replicas that are caught up, and gtid.source.includes or gtid.source.excludes restrict the GTID sources it considers.

Hosted (Amazon RDS, Amazon Aurora)

Global read locks are not allowed, so the snapshot uses table-level locks.

For a migration, reading from a replica is often the best choice: the legacy primary keeps its full capacity for the application, and the replica is the place where you can change binlog settings without a change window on the primary. The replica must write its own binlog with the replicated changes (log_replica_updates, which is on by default in MySQL 8.0 and later), and you should enable GTIDs so that the connector can move to another server later.

Preparing MySQL

The connector user

The connector needs a user with these global privileges:

Privilege Why

SELECT

Read rows during snapshots.

RELOAD

Use FLUSH to take the global read lock during snapshots.

SHOW DATABASES

See the database names during snapshots.

REPLICATION SLAVE

Connect to the server and read the binlog.

REPLICATION CLIENT

Read the binlog status and the list of binlog files. Always required.

LOCK TABLES

Only where global read locks are not allowed (Amazon RDS, Aurora): the snapshot then locks tables.

The official example grants them with GRANT ... IDENTIFIED BY 'password'. That form was removed in MySQL 8.0, where a GRANT cannot create a user or set a password. On MySQL 8.0, 8.4 and 9.x, and on MariaDB, create the user first and grant separately. This is the script that ran in the lab:

Creating the connector user (MySQL 8.x and MariaDB)
CREATE USER 'debezium'@'%' IDENTIFIED BY 'dbz_pw';
GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT, LOCK TABLES
  ON *.* TO 'debezium'@'%';
-- The connector writes incremental-snapshot watermarks to the signal table
GRANT INSERT, UPDATE, DELETE ON shop.debezium_signal TO 'debezium'@'%';
FLUSH PRIVILEGES;

Restrict the host part ('debezium'@'10.20.%' instead of '%') to the Kafka Connect network in production. REPLICATION SLAVE and SELECT on *.* give the user read access to every database on the server, which is inherent to binlog-based CDC: the binlog contains every database’s changes. If the server holds data that the migration must not read, plan for that (see Security & Data Protection).

Enabling and configuring the binlog

The binlog must be enabled, in row format, with full row images. MySQL 8.0 and later enable the binlog by default, with binlog_format=ROW and binlog_row_image=FULL as defaults, but legacy servers are often MySQL 5.7, or have these settings changed for disk or performance reasons. Always check.

Checking whether the binlog is enabled (MySQL 8.x)
SELECT variable_value AS "BINARY LOGGING STATUS (log-bin) ::"
FROM performance_schema.global_variables WHERE variable_name = 'log_bin';

SHOW GLOBAL VARIABLES WHERE variable_name IN
  ('server_id', 'log_bin', 'binlog_format', 'binlog_row_image',
   'binlog_row_value_options', 'binlog_expire_logs_seconds', 'gtid_mode');

On MySQL 5.x, query information_schema.global_variables instead of performance_schema.global_variables. If the binlog is off or the formats are wrong, set them in the server’s configuration file and restart:

my.cnf settings for the Debezium MySQL connector
[mysqld]
server-id                  = 223344      # unique in the replication topology
log_bin                    = mysql-bin   # base name of the binlog files
binlog_format              = ROW
binlog_row_image           = FULL
binlog_expire_logs_seconds = 864000      # 10 days of binlog retention

What each setting means for a migration:

Setting Meaning

server-id

Must be unique for every server and replication client in the cluster. The connector’s own ID (database.server.id) must differ from every server-id too.

log_bin

The base name of the binlog files (mysql-bin.000001, mysql-bin.000002, …​).

binlog_format=ROW

STATEMENT or MIXED binlogs contain SQL text instead of row values. Debezium cannot use them.

binlog_row_image=FULL

With MINIMAL, updates contain only changed columns and the key, so before and after are incomplete.

binlog_expire_logs_seconds

How long the server keeps binlog files (replaces the deprecated expire_logs_days). The default is 2592000 (30 days). This is the longest the connector can be stopped without needing a new snapshot.

Binlog retention is the MySQL equivalent of PostgreSQL’s slot retention, but inverted: PostgreSQL keeps WAL until the connector confirms it (and risks the disk); MySQL deletes binlog files after a time (and risks the connector’s position). Set the retention longer than the longest outage you want to survive without a re-snapshot, for example a holiday weekend plus the time to fix the connector, and alert when the connector has been down for half of it.

The binlog_row_value_options check

MySQL 8.0 can log partial updates of JSON columns (binlog_row_value_options=PARTIAL_JSON). The connector cannot consume such updates, so the variable must be empty:

Validating binlog_row_value_options
SHOW GLOBAL VARIABLES WHERE variable_name = 'binlog_row_value_options';
-- If the value is PARTIAL_JSON, unset it:
SET @@global.binlog_row_value_options = "";

SET @@global lasts until the next restart. Also remove PARTIAL_JSON from the configuration file, or use SET PERSIST on MySQL 8.0 and later.

GTIDs

A global transaction identifier (GTID) names each transaction uniquely across the topology (source_uuid:transaction_number). GTIDs are not required, but for a migration they are strongly recommended: they let the connector find its position on a different server after a failover, and they make it easy to check whether a replica has caught up. The official documentation shows the two server options as gtid_mode=ON and enforce_gtid_consistency=ON. Set them in the configuration file (or on the command line, as the lab does):

my.cnf settings for GTIDs
[mysqld]
gtid_mode                = ON
enforce_gtid_consistency = ON
Confirming GTID mode
SHOW GLOBAL VARIABLES LIKE '%GTID%';
-- enforce_gtid_consistency | ON
-- gtid_mode                | ON

On a running legacy primary with replicas, gtid_mode cannot jump from OFF to ON; MySQL requires the steps OFF_PERMISSIVE, ON_PERMISSIVE and then ON, as described in the MySQL GTID documentation. Plan that as its own change before the migration starts.

Related connector properties: gtid.source.includes and gtid.source.excludes (regular expressions on the GTID source; set at most one of them) restrict the GTID ranges the connector uses to find its position, and gtid.ignore.on.recovery=true makes the connector resume from the stored binlog file and position instead of the GTID set, for example after a server’s GTID history was reset.

Query log events

With binlog_rows_query_log_events=ON (MySQL), the binlog also contains the SQL statement that produced each row event. With include.query=true in the connector, that statement appears in the event’s source.query field. During a migration this helps you find which part of the legacy application changed a row, which is useful when you reconcile differences. The official documentation warns that the query can reveal values of columns that you excluded or masked with other settings, so do not enable it for tables with sensitive data, and do not keep it on in production longer than needed. Snapshot events never contain a query.

Enabling query log events on MySQL
[mysqld]
binlog_rows_query_log_events = ON

The connector property description of include.query names the MariaDB variable binlog_annotate_row_events; on MySQL, the variable to set is binlog_rows_query_log_events, as the setup section of the same page says. The lab confirmed it: with binlog_rows_query_log_events=ON on MySQL 8.4, source.query contained the original UPDATE.

Session timeouts

A snapshot of a large legacy table can take hours, and the server can close the connection in the meantime. If that happens, raise interactive_timeout and wait_timeout on the server for the duration of the snapshot.

A tested lab: the legacy shop database

The lab runs Kafka in KRaft mode, Kafka Connect with the Debezium connectors, a MySQL 8.4 server and a MariaDB 11.8 server that both hold the same legacy shop schema. The server options are passed on the command line, which has the same effect as the configuration-file settings above.

compose.yaml: legacy shop on MySQL 8.4 and MariaDB 11.8
services:
  kafka:
    image: quay.io/debezium/kafka:3.7.1.Final
    hostname: kafka
    ports:
      - "9092:9092"
    environment:
      - CLUSTER_ID=5Yr1SIgYQz-b-dgRabWx4g
      - NODE_ID=1
      - NODE_ROLE=combined
      - KAFKA_CONTROLLER_QUORUM_VOTERS=1@kafka:9093
      - KAFKA_LISTENERS=PLAINTEXT://kafka:9092,CONTROLLER://kafka:9093
      - KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092

  mysql:
    image: mysql:8.4
    command: ["--server-id=223344", "--log-bin=mysql-bin",
              "--binlog-expire-logs-seconds=864000",
              "--gtid-mode=ON", "--enforce-gtid-consistency=ON",
              "--binlog-rows-query-log-events=ON"]
    environment:
      MYSQL_ROOT_PASSWORD: rootpw
    volumes:
      - ./shop-init.sql:/docker-entrypoint-initdb.d/10-init.sql:ro

  mariadb:
    image: mariadb:11.8
    command: ["--server-id=223345", "--log-bin=mariadb-bin",
              "--binlog-format=ROW", "--binlog-row-image=FULL",
              "--binlog-legacy-event-pos=ON",
              "--binlog-annotate-row-events=ON"]
    environment:
      MARIADB_ROOT_PASSWORD: rootpw
    volumes:
      - ./shop-init.sql:/docker-entrypoint-initdb.d/10-init.sql:ro

  connect:
    image: quay.io/debezium/connect:3.7.1.Final
    ports:
      - "8083:8083"
    depends_on: [kafka, mysql, mariadb]
    environment:
      BOOTSTRAP_SERVERS: kafka:9092
      GROUP_ID: shop-connect
      CONFIG_STORAGE_TOPIC: connect_configs
      OFFSET_STORAGE_TOPIC: connect_offsets
      STATUS_STORAGE_TOPIC: connect_statuses

The quay.io/debezium images are meant for testing and evaluation; the official documentation says they are not intended for production. Production installation options are on Installing Debezium. Give Docker enough memory for Kafka, Connect and the database together. When the host runs out of memory, the kernel stops containers (exit code 137), which looks like a connector failure but is not one: check docker inspect for OOMKilled first.

The legacy schema deliberately contains the types that cause trouble in migrations: a TINYINT(1) flag, a BIGINT UNSIGNED key, an ENUM, a DATETIME and a TIMESTAMP(3).

shop-init.sql: the legacy schema, the signal table and the connector user
CREATE DATABASE shop;
CREATE TABLE shop.customer (
  id      INT AUTO_INCREMENT PRIMARY KEY,
  name    VARCHAR(200) NOT NULL,
  email   VARCHAR(320),
  active  TINYINT(1) NOT NULL DEFAULT 1,
  created DATETIME NOT NULL
);
CREATE TABLE shop.orders (
  id          BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  customer_id INT NOT NULL,
  status      ENUM('NEW','PAID','SHIPPED','CANCELLED') NOT NULL,
  total       DECIMAL(12,2) NOT NULL,
  placed_at   TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3)
);
CREATE TABLE shop.debezium_signal (
  id   VARCHAR(42) PRIMARY KEY,
  type VARCHAR(32) NOT NULL,
  data VARCHAR(2048) NULL
);
INSERT INTO shop.customer (name, email, active, created)
  VALUES ('Ada Lovelace', 'ada@example.com', 1, '2019-03-01 10:00:00');
INSERT INTO shop.orders (customer_id, status, total) VALUES (1, 'PAID', 42.50);

CREATE USER 'debezium'@'%' IDENTIFIED BY 'dbz_pw';
GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT, LOCK TABLES
  ON *.* TO 'debezium'@'%';
GRANT INSERT, UPDATE, DELETE ON shop.debezium_signal TO 'debezium'@'%';
FLUSH PRIVILEGES;

The MySQL connector configuration

shop-mysql-source.json
{
  "name": "shop-mysql-source",
  "config": {
    "connector.class": "io.debezium.connector.mysql.MySqlConnector",
    "tasks.max": "1",
    "database.hostname": "mysql",
    "database.port": "3306",
    "database.user": "debezium",
    "database.password": "dbz_pw",
    "database.server.id": "184054",
    "topic.prefix": "legacy-shop",
    "database.include.list": "shop",
    "table.include.list": "shop.customer,shop.orders",
    "schema.history.internal.kafka.bootstrap.servers": "kafka:9092",
    "schema.history.internal.kafka.topic": "legacy-shop.schema-history",
    "include.schema.changes": "true",
    "snapshot.mode": "initial",
    "snapshot.locking.mode": "minimal",
    "bigint.unsigned.handling.mode": "precise",
    "decimal.handling.mode": "string",
    "heartbeat.interval.ms": "10000",
    "signal.data.collection": "shop.debezium_signal",
    "include.query": "true",
    "converters": "boolean",
    "boolean.type": "io.debezium.connector.binlog.converters.TinyIntOneToBooleanConverter",
    "boolean.selector": "shop.customer.active"
  }
}
Registering the connector
curl -s -X POST -H 'Content-Type: application/json' \
     --data @shop-mysql-source.json http://localhost:8083/connectors
curl -s http://localhost:8083/connectors/shop-mysql-source/status

The properties that need explanation:

Property Meaning

database.server.id

The connector’s numeric ID when it joins the replication topology as a replica. It must be unique among all servers and replication clients, including other Debezium connectors on the same server. A duplicate ID makes the server drop one of the two connections.

topic.prefix

Namespace of all topics and schema names. Do not change it after the first start: the offsets are stored under it.

database.include.list / table.include.list

What to capture. The signal table does not need to be in the include list.

schema.history.internal.kafka.topic / schema.history.internal.kafka.bootstrap.servers

Where the connector stores the DDL history (see the next section). Required.

include.schema.changes

Default true. Also publishes schema changes to a topic named after topic.prefix, for consumers. This is separate from the internal schema history.

snapshot.locking.mode

Default minimal. How long the global read lock is held during the snapshot (see Snapshots and locking).

heartbeat.interval.ms

Emits heartbeats so that offsets advance when the captured tables are quiet. Required by the official procedure for the set-binlog-position signal.

What the events look like

The snapshot read the existing rows, then the lab ran an UPDATE on customer and an INSERT into orders. These are trimmed payloads from legacy-shop.shop.customer and legacy-shop.shop.orders:

Snapshot and streaming events from shop-mysql-source
{ "op": "r",
  "after":  { "id": 1, "name": "Ada Lovelace", "email": "ada@example.com", "active": true,
              "created": 1551434400000 },
  "source": { "connector": "mysql", "snapshot": "first", "server_id": 0, "gtid": null,
              "file": "mysql-bin.000003", "pos": 198, "row": 0, "query": null } }

{ "op": "u",
  "after":  { "id": 1, "name": "Ada Lovelace", "email": "ada@lovelace.example", "active": false,
              "created": 1551434400000 },
  "source": { "connector": "mysql", "snapshot": "false", "server_id": 223344,
              "gtid": "e9687ec2-dc1a-11f1-bb74-e2a60528b246:16",
              "file": "mysql-bin.000003", "pos": 522, "row": 0,
              "query": "UPDATE customer SET email='ada@lovelace.example', active=0 WHERE id=1" } }

{ "op": "c",
  "after":  { "id": "Ag==", "customer_id": 1, "status": "NEW", "total": "10.00",
              "placed_at": "2026-11-09T08:59:44.754Z" },
  "source": { "connector": "mysql", "snapshot": "false", "server_id": 223344,
              "gtid": "e9687ec2-dc1a-11f1-bb74-e2a60528b246:17",
              "file": "mysql-bin.000003", "pos": 989, "row": 0,
              "query": "INSERT INTO orders (customer_id,status,total) VALUES (1,'NEW',10.00)" } }

What to notice:

  • Snapshot events have "op": "r" and a source.snapshot value that marks their place in the snapshot (the run shows first and last); server_id is 0 because they were not read from the binlog. Streaming events carry the server ID, the binlog file and position, the row number within the event, and the GTID. Together, file, pos and row (or the GTID) identify a change, which is what an idempotent consumer stores in its processed_change table.

  • source.query contains the original SQL statement because of include.query=true and binlog_rows_query_log_events=ON.

  • active is a boolean, because the TINYINT(1) converter was applied to shop.customer.active.

  • created (DATETIME) is milliseconds since the epoch with no time zone, while placed_at (TIMESTAMP(3)) is an ISO-8601 string in UTC. DATETIME values have no zone in MySQL, so the consumer must know which zone the legacy application used. See Data Types & Precision.

  • id of orders (BIGINT UNSIGNED) arrived as "Ag==": with bigint.unsigned.handling.mode=precise, the value is a Kafka Connect Decimal, which the JSON converter writes as base64 bytes. decimal.handling.mode=string does not change that, and the key of the message is encoded the same way. Use precise only if the column really holds values above 2^63 - 1; otherwise the default long gives plain numbers. The official documentation warns that with long, larger values silently become negative.

  • status (ENUM) arrived as the string "NEW".

The schema history topic

Because binlog row events carry no column metadata, the connector must know each table’s structure as it was at the binlog position being read, which may be days behind the current schema after an outage. It keeps that knowledge in the schema history topic: every DDL statement from the binlog, with its position. On restart, it replays the topic up to its offset to rebuild the table structures, and then continues reading the binlog.

For a migration, that has four consequences:

  • The topic must never be deleted, compacted or truncated by retention. Create it with one partition, infinite retention (retention.ms=-1) and no compaction; topic requirements are on Installing Debezium. If it is lost, the connector cannot start. snapshot.mode=recovery (formerly schema_only_recovery, now deprecated) rebuilds it from the current table structures, but only safely if no schema change was committed since the connector stopped.

  • It is internal. Consumers that need DDL use the schema change topic (include.schema.changes=true), not the history topic.

  • Keep the default schema.history.internal.store.only.captured.tables.ddl=false. The connector then stores the structure of every table, so you can add tables to the capture later without a new snapshot. With true, a table added later lacks history and needs extra steps.

  • Online schema-change tools need care. gh-ost and pt-online-schema-change create helper tables and rename them at the end. The official documentation says you must capture those helper tables, and filter their events out with an SMT if consumers do not need them. Coordinate any such change on a captured table with Handling Schema Changes.

Schema history properties for a production connector
{
  "schema.history.internal.kafka.topic": "legacy-shop.schema-history",
  "schema.history.internal.kafka.bootstrap.servers": "kafka:9092",
  "schema.history.internal.kafka.recovery.attempts": "100",
  "schema.history.internal.kafka.recovery.poll.interval.ms": "100",
  "schema.history.internal.skip.unparseable.ddl": "false",
  "schema.history.internal.store.only.captured.tables.ddl": "false"
}

schema.history.internal.skip.unparseable.ddl=true lets the connector continue past DDL it cannot parse. The official documentation calls false the safe default and warns that skipping can lead to lost or mangled data. If the DDL parser fails on a legacy statement, ddl.parser.type=legacy switches to the older grammar, which the official documentation offers for compatibility with existing DDL.

The connector exposes schema history metrics under debezium.mysql:type=connector-metrics,context=schema-history,server=<topic.prefix>.

Snapshots and locking

On the first start with snapshot.mode=initial, the connector copies the current data and records the binlog position at which the copy is consistent. With a global read lock, the default workflow is:

  1. Connect, and determine the tables to capture.

  2. Take a global read lock (FLUSH TABLES WITH READ LOCK), which blocks writes from every client.

  3. Start a REPEATABLE READ transaction with a consistent snapshot.

  4. Read the current binlog position and the structure of the tables.

  5. With snapshot.locking.mode=minimal, release the global lock.

  6. Read all rows of each table inside the transaction, and emit them as op=r events.

  7. Commit the transaction, record the offset, and start reading the binlog from the recorded position.

So with the default mode, the legacy application is blocked for writes only while the connector reads the schema and the binlog position, usually seconds. The REPEATABLE READ transaction keeps the rest of the snapshot consistent without locks.

snapshot.locking.mode Behaviour

minimal (default)

Global read lock only while schemas and the binlog position are read; then a REPEATABLE READ transaction.

extended

Blocks all writes for the whole snapshot. Only for clients whose concurrent operations are incompatible with REPEATABLE READ.

none

No locks. Safe only if no schema change happens during the snapshot. MyISAM tables are always locked anyway.

custom

A SnapshotLock implementation named by snapshot.locking.mode.custom.name.

Where global read locks are not allowed (Amazon RDS, Aurora, or a DBA policy), the connector detects that and uses table-level locks instead, which requires the LOCK TABLES privilege. Table locks are held longer, so schedule the initial snapshot of a hosted legacy database for a quiet period.

Legacy MySQL databases often contain MyISAM tables. They do not support transactions, so the consistent-read approach does not apply to them and they stay locked during their snapshot. Consider converting them to InnoDB before the migration, or snapshot them separately.

The snapshot modes of the binlog connectors:

snapshot.mode Behaviour

initial (default)

Snapshot when no offset exists, or when an earlier snapshot did not finish; then stream.

initial_only

Snapshot, then stop.

always

Snapshot at every start.

no_data (replaces schema_only)

Capture only the schema, then stream.

recovery (replaces schema_only_recovery)

Rebuild a lost or corrupted schema history topic.

when_needed

Snapshot if there is no offset, or the stored binlog position or GTID is no longer on the server.

configuration_based / custom

Controlled by snapshot.mode.configuration.based.* properties, or by a Snapshotter implementation.

snapshot.max.threads above 1 splits each table into primary-key ranges and reads them in parallel (an incubating feature). For very large legacy tables, the alternative is snapshot.mode=no_data followed by an incremental snapshot that runs while streaming, without long locks (see Incremental & Blocking Snapshots and Initial Snapshots).

Snapshot settings for a large hosted legacy database
{
  "snapshot.mode": "initial",
  "snapshot.locking.mode": "minimal",
  "snapshot.max.threads": "4",
  "snapshot.fetch.size": "10000"
}

Moving the binlog position with a signal

Sometimes you need the connector to read from a specific point in the binlog: after restoring the legacy database from a backup (so that old events are not replayed), to skip a range of corrupted changes, or to resume from the last known good position after a disaster. The set-binlog-position signal does this. Its data contains either a binlog file and position, or a GTID set, never both:

  • File and position (GTID mode off): {"binlog_filename": "mysql-bin.000003", "binlog_position": 1234}. The file name must match the server’s binlog naming pattern.

  • GTID set (GTID mode on): {"gtid_set": "3E11FA47-71CA-11E1-9E33-C80AA9429562:1-100"} for MySQL, or {"gtid_set": "0-1-100"} (domain-server-sequence) for MariaDB.

Moving forward skips every change in between: those changes are never captured. Moving backward replays changes that were already sent, producing duplicates. Either way, record why you did it, because reconciliation will find the consequences (see Verification & Reconciliation).

The prerequisites are a configured signal channel, the signal table, and heartbeat.interval.ms set so that the new offset is persisted.

Repositioning the MySQL connector with the source signal channel
-- GTID mode disabled: binlog file and position
INSERT INTO shop.debezium_signal (id, type, data) VALUES (
  'set-position-001',
  'set-binlog-position',
  '{"binlog_filename": "mysql-bin.000003", "binlog_position": 1234}'
);

-- GTID mode enabled: GTID set
INSERT INTO shop.debezium_signal (id, type, data) VALUES (
  'set-gtid-001',
  'set-binlog-position',
  '{"gtid_set": "3E11FA47-71CA-11E1-9E33-C80AA9429562:1-100"}'
);

After the signal, restart the connector so that it starts streaming from the new position, as the last step of the official procedure says.

Restarting the connector after the signal
curl -s -X POST "http://localhost:8083/connectors/shop-mysql-source/restart?includeTasks=true"

Signals, including incremental snapshots of the shop tables, are covered in general on Signaling & Notifications.

Data-type pitfalls in legacy MySQL schemas

Legacy MySQL schemas use types that do not map cleanly to a new model. The connector has three built-in custom converters for them, all in the package io.debezium.connector.binlog.converters (shared by the MySQL and MariaDB connectors).

TINYINT(1) used as a boolean

MySQL has no real boolean: BOOLEAN is TINYINT(1). During the snapshot the connector takes column types from the JDBC driver, and during streaming from the parsed DDL, which can lead to inconsistent mappings. The TinyIntOneToBooleanConverter maps selected TINYINT(1) columns to a boolean in both phases. Without selector, it applies to every TINYINT column of length 1; length.checker=false also converts TINYINT columns of other lengths.

TinyIntOneToBooleanConverter
converters=boolean
boolean.type=io.debezium.connector.binlog.converters.TinyIntOneToBooleanConverter
boolean.selector=shop.customer.active

Zero dates

Legacy MySQL schemas often contain 0000-00-00 dates (allowed in older SQL modes). Debezium cannot represent them, so by default it emits null for a nullable column and the epoch (1970-01-01) for a NOT NULL column. The epoch value is a silent data change: a new system would see a real date. The ZeroDateFallbackConverter lets you choose the value per type or per column, including NULL for NOT NULL columns.

ZeroDateFallbackConverter
converters=zero-date
zero-date.type=io.debezium.connector.binlog.converters.ZeroDateFallbackConverter
zero-date.target.types=DATE,DATETIME,TIMESTAMP
zero-date.fallback.date=NULL
zero-date.fallback.datetime=NULL
zero-date.fallback.timestamp=NULL
zero-date.column.shop.orders.shipped_at.fallback=NULL
zero-date.selector=.*

Feeding the JDBC sink

The MySQL connector emits some column attributes differently in the snapshot and in streaming. If the events go to the Debezium JDBC sink, add the JdbcSinkDataTypesConverter to the source connector, so that booleans are always INT16, REAL columns are always FLOAT64, and string columns carry the __debezium.source.column.character_set parameter.

JdbcSinkDataTypesConverter
converters=jdbc-sink
jdbc-sink.type=io.debezium.connector.binlog.converters.JdbcSinkDataTypesConverter
jdbc-sink.selector.boolean=.*.customer.active
jdbc-sink.treat.real.as.double=true

Several converters can be combined in one converters list (converters=boolean,zero-date). The JDBC sink itself is on JDBC Sink Connector, and other type questions (DECIMAL, BIGINT UNSIGNED, DATETIME and time zones, time.precision.mode) are on Data Types & Precision.

Two more properties matter for legacy MySQL types:

Property Default Notes

bigint.unsigned.handling.mode

long

precise emits a Decimal (binary in JSON) and is needed only for values above 2^63 - 1.

time.precision.mode

adaptive_time_microseconds

connect uses millisecond Kafka Connect types; isostring emits ISO-8601 strings in UTC; adaptive is deprecated.

inconsistent.schema.handling.mode

fail

What to do with binlog events for tables missing from the in-memory schema (fail, warn, skip). Keep fail during a migration: a skipped event is a missing row in the new database.

The MariaDB connector

MariaDB started as a fork of MySQL, and its binlog is close to MySQL’s, but its GTIDs, binary log format and TLS options differ. Use the dedicated connector, io.debezium.connector.mariadb.MariaDbConnector, packaged as a separate plug-in. Its configuration properties, snapshot behaviour, schema history and signals are the same as for MySQL, including the set-binlog-position signal and the io.debezium.connector.binlog.converters converters.

Differences at a glance

Topic MySQL connector MariaDB connector

Connector class

io.debezium.connector.mysql.MySqlConnector

io.debezium.connector.mariadb.MariaDbConnector

Binlog file names in the examples

mysql-bin.000001

mariadb-bin.000001

Checking the binlog

SELECT ... FROM performance_schema.global_variables WHERE variable_name='log_bin'

SHOW VARIABLES LIKE '%log_bin%'

GTIDs

Off by default; enable gtid_mode and enforce_gtid_consistency. Format source_uuid:transaction_ids.

Enabled by default, no configuration needed. Format domain-server-sequence, for example 0-1-100.

Original SQL in events (include.query=true)

binlog_rows_query_log_events=ON

binlog_annotate_row_events=ON

New binlog format

 — 

MariaDB 11.4 and later: set binlog_legacy_event_pos=1 (ON), or the connector may not find its resume point after a restart.

Binlog compression

 — 

Not supported: log_bin_compress must be 0 (the default).

InnoDB-based binlog

 — 

MariaDB 12.3 and later can store the binlog in InnoDB (binlog_storage_engine=innodb, .ibb files). Needs GTIDs; log_bin must be present without a value.

database.ssl.mode

Default preferred; values disabled, preferred, required, verify_ca, verify_identity.

Default disable; values disable, trust, verify-ca, verify-full.

database.jdbc.driver, database.protocol

Available (defaults com.mysql.cj.jdbc.Driver, jdbc:mysql).

Not listed in the MariaDB properties.

JMX MBean domain

debezium.mysql

debezium.mariadb

The MariaDB versions tested with Debezium 3.7 are 11.4, 11.8 and 12.3. A legacy MariaDB 10.x server is not in that list; upgrade it, or test the connector against it before you rely on it.

Preparing MariaDB

MariaDB server configuration for the Debezium MariaDB connector
[mariadb]
server-id                  = 223345
log_bin                    = mariadb-bin
binlog_format              = ROW
binlog_row_image           = FULL
binlog_expire_logs_seconds = 864000
binlog_legacy_event_pos    = ON      # required for MariaDB 11.4 and later
log_bin_compress           = 0       # compressed binlog events are not supported
binlog_annotate_row_events = ON      # only if you use include.query=true
Checking the MariaDB binlog settings
SHOW VARIABLES LIKE '%log_bin%';
SHOW GLOBAL VARIABLES WHERE variable_name IN
  ('binlog_format', 'binlog_row_image', 'binlog_legacy_event_pos', 'gtid_current_pos');

For MariaDB 12.3 and later, the InnoDB-based binlog replaces the file-based binlog entirely. It does not support Galera Cluster or semi-synchronous replication, and sync_binlog no longer applies:

MariaDB 12.3+: InnoDB-based binary log
[mariadb]
log_bin
binlog_storage_engine = innodb
binlog_format         = ROW
binlog_row_image      = FULL

The user and grants are the same as for MySQL (create the user, then grant; see the script above).

The MariaDB connector configuration

The lab ran the same shop schema on MariaDB 11.8 with this configuration:

shop-mariadb-source.json
{
  "name": "shop-mariadb-source",
  "config": {
    "connector.class": "io.debezium.connector.mariadb.MariaDbConnector",
    "tasks.max": "1",
    "database.hostname": "mariadb",
    "database.port": "3306",
    "database.user": "debezium",
    "database.password": "dbz_pw",
    "database.server.id": "184055",
    "topic.prefix": "legacy-shop-maria",
    "database.include.list": "shop",
    "table.include.list": "shop.customer,shop.orders",
    "schema.history.internal.kafka.bootstrap.servers": "kafka:9092",
    "schema.history.internal.kafka.topic": "legacy-shop-maria.schema-history",
    "include.schema.changes": "true",
    "snapshot.mode": "initial",
    "snapshot.locking.mode": "minimal",
    "bigint.unsigned.handling.mode": "precise",
    "decimal.handling.mode": "string",
    "heartbeat.interval.ms": "10000",
    "signal.data.collection": "shop.debezium_signal",
    "include.query": "true",
    "converters": "boolean",
    "boolean.type": "io.debezium.connector.binlog.converters.TinyIntOneToBooleanConverter",
    "boolean.selector": "shop.customer.active"
  }
}

The resulting update event shows the MariaDB-specific source values: connector is mariadb, the binlog file is mariadb-bin.*, and the GTID is in MariaDB’s domain-server-sequence form, present without any GTID configuration:

Update event from shop-mariadb-source (trimmed)
{ "op": "u",
  "after":  { "id": 1, "name": "Ada Lovelace", "email": "ada@lovelace.example", "active": false,
              "created": 1551434400000 },
  "source": { "version": "3.7.1.Final", "connector": "mariadb", "name": "legacy-shop-maria",
              "snapshot": "false", "db": "shop", "table": "customer", "server_id": 223345,
              "gtid": "0-223345-11", "file": "mariadb-bin.000002", "pos": 538, "row": 0,
              "query": "UPDATE customer SET email='ada@lovelace.example', active=0 WHERE id=1" } }

MySQL and MariaDB in the cloud

The official documentation covers Amazon RDS and Aurora:

  • Automated backups must be enabled. On RDS, the binlog is written only when automated backups are on, even if the parameter group sets the binlog options.

  • No global read lock. The connector uses table-level locks for the snapshot; grant LOCK TABLES.

  • Binlog retention is an RDS setting. RDS removes binlog files quickly by default. Set the retention with the RDS stored procedure described in the AWS documentation, longer than the longest connector outage you want to survive.

  • Parameter groups. Set binlog_format=ROW (and, if needed, binlog_row_image=FULL) in the DB parameter group (DB cluster parameter group for Aurora).

Amazon RDS for MySQL: binlog retention
CALL mysql.rds_set_configuration('binlog retention hours', 168);
CALL mysql.rds_show_configuration;

Other managed services (Cloud SQL for MySQL, Azure Database for MySQL) also expose binary logging through their own settings; the Debezium documentation does not describe them. Check the binlog format, row image, retention and whether the service allows FLUSH TABLES WITH READ LOCK before you plan the snapshot. A comparison of managed databases and managed Kafka is on Cloud Databases & Managed Kafka.

Monitoring

MBeans are named after topic.prefix, with the domain debezium.mysql or debezium.mariadb:

  • debezium.mysql:type=connector-metrics,context=snapshot,server=<topic.prefix>

  • debezium.mysql:type=connector-metrics,context=streaming,server=<topic.prefix>

  • debezium.mysql:type=connector-metrics,context=schema-history,server=<topic.prefix>

Besides the common streaming metrics (Connected, MilliSecondsBehindSource and its min, max, average and P50, P95 and P99 values, MilliSecondsSinceLastEvent, TotalNumberOfEventsSeen, QueueRemainingCapacity), the binlog connectors expose:

Attribute Why you watch it

BinlogFilename, BinlogPosition

Where the connector is. Compare with SHOW BINARY LOGS to see how close the oldest retained file is.

IsGtidModeEnabled, GtidSet

Confirms GTID positioning, and the set the connector has processed.

NumberOfSkippedEvents

Events skipped (for example by inconsistent.schema.handling.mode=warn). Must stay 0 in a migration.

NumberOfDisconnects

Repeated binlog reconnects point to network or timeout problems.

NumberOfLargeTransactions, NumberOfRolledBackTransactions, NumberOfNotWellFormedTransactions

Unusual transaction patterns in the legacy application.

The most important alert for a binlog connector is time: how long the connector has not advanced, compared with the binlog retention. Dashboards are on Monitoring, Logging & Tracing.

Comparing the connector’s binlog file with the files the server still has
SHOW BINARY LOGS;          -- MySQL 8.4 and MariaDB
SELECT @@GLOBAL.gtid_executed;   -- MySQL: GTIDs the server has executed

When things go wrong

Situation What happens What to do

Invalid configuration or credentials, or the stored binlog position is no longer on the server

The connector fails at start-up with an error.

Fix the configuration. For a lost position, the connector needs a new snapshot (when_needed), or an incremental snapshot after no_data.

The server becomes unavailable

The connector fails and stops.

Restart it when the server is back. With a highly available cluster and GTIDs, you can restart it at once: it connects to another server and finds its position by GTID.

The binlog was purged while the connector was stopped

With snapshots enabled, the connector takes a new initial snapshot. With snapshots disabled, it fails.

Increase binlog retention, alert on connector downtime, and plan the re-snapshot load on the legacy database.

Kafka Connect crashes

Tasks restart from the last committed offset; some events are emitted again.

Consumers must be idempotent (use the binlog file, position and row, or the GTID).

Kafka becomes unavailable

The connector pauses and resumes where it stopped.

Make sure binlog retention covers the Kafka outage.

Two connectors, or a connector and a replica, use the same server ID

The server disconnects one of them, repeatedly.

Give each connector a unique database.server.id.

The schema history topic was deleted or compacted

The connector cannot rebuild table structures and fails.

Restore it, or use snapshot.mode=recovery if no schema change happened since the connector stopped.

DDL that the parser cannot handle

The connector stops.

Try ddl.parser.type=legacy; use schema.history.internal.skip.unparseable.ddl=true only after checking that the statement does not change a captured table.

binlog_row_image=MINIMAL or PARTIAL_JSON

Incomplete before/after values, or update events that cannot be consumed.

Set FULL and an empty binlog_row_value_options.

MariaDB 11.4+ without binlog_legacy_event_pos

After a restart, the connector may not find its resume point.

Set binlog_legacy_event_pos=ON.

The official sections, and recovery procedures that apply to all connectors, are on Troubleshooting & Failure Recovery and Offsets, Restarts & Exactly-Once.

Verification checklist

  • log_bin is on, binlog_format=ROW, binlog_row_image=FULL, binlog_row_value_options is empty, and the server (or the replica the connector reads) has a unique server-id.

  • Binlog retention is longer than the longest outage you accept without a re-snapshot, and an alert fires well before it.

  • GTIDs are enabled on MySQL (on by default on MariaDB).

  • The connector user was created with CREATE USER, has only the listed privileges, and LOCK TABLES where global read locks are not allowed.

  • Each connector has a unique database.server.id and its own schema history topic, with infinite retention and no compaction.

  • The first snapshot was timed on a copy of the legacy data, and the lock duration is acceptable.

  • TINYINT(1) flags, zero dates, BIGINT UNSIGNED keys and DATETIME time zones have a decision and, where needed, a converter.

  • include.query is off for tables with sensitive data.

  • For MariaDB 11.4 and later: binlog_legacy_event_pos=ON and log_bin_compress=0.