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.
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
|
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 |
|---|---|
|
Read rows during snapshots. |
|
Use |
|
See the database names during snapshots. |
|
Connect to the server and read the binlog. |
|
Read the binlog status and the list of binlog files. Always required. |
|
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:
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;
Reference: Debezium — MySQL: Creating a user
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.
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');
Reference: Debezium — MySQL: Enabling the binlog
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:
[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 |
|---|---|
|
Must be unique for every server and replication client in the cluster. The connector’s own ID
( |
|
The base name of the binlog files ( |
|
|
|
With |
|
How long the server keeps binlog files (replaces the deprecated |
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:
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):
[mysqld]
gtid_mode = ON
enforce_gtid_consistency = ON
Reference: Debezium — MySQL: Enabling GTIDs
SHOW GLOBAL VARIABLES LIKE '%GTID%';
-- enforce_gtid_consistency | ON
-- gtid_mode | ON
Reference: Debezium — MySQL: Enabling GTIDs
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.
[mysqld]
binlog_rows_query_log_events = ON
Reference: Debezium — MySQL: Enabling query log events
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.
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.
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
Reference: Debezium — MySQL connector deployment
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).
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
{
"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"
}
}
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 |
|---|---|
|
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. |
|
Namespace of all topics and schema names. Do not change it after the first start: the offsets are stored under it. |
|
What to capture. The signal table does not need to be in the include list. |
|
Where the connector stores the DDL history (see the next section). Required. |
|
Default |
|
Default |
|
Emits heartbeats so that offsets advance when the captured tables are quiet. Required by the official procedure
for the |
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:
{ "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)" } }
Reference: Debezium — MySQL create events
What to notice:
-
Snapshot events have
"op": "r"and asource.snapshotvalue that marks their place in the snapshot (the run showsfirstandlast);server_idis0because 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,posandrow(or the GTID) identify a change, which is what an idempotent consumer stores in itsprocessed_changetable. -
source.querycontains the original SQL statement because ofinclude.query=trueandbinlog_rows_query_log_events=ON. -
activeis a boolean, because the TINYINT(1) converter was applied toshop.customer.active. -
created(DATETIME) is milliseconds since the epoch with no time zone, whileplaced_at(TIMESTAMP(3)) is an ISO-8601 string in UTC.DATETIMEvalues have no zone in MySQL, so the consumer must know which zone the legacy application used. See Data Types & Precision. -
idoforders(BIGINT UNSIGNED) arrived as"Ag==": withbigint.unsigned.handling.mode=precise, the value is a Kafka ConnectDecimal, which the JSON converter writes as base64 bytes.decimal.handling.mode=stringdoes not change that, and the key of the message is encoded the same way. Usepreciseonly if the column really holds values above2^63 - 1; otherwise the defaultlonggives plain numbers. The official documentation warns that withlong, 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(formerlyschema_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. Withtrue, 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.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"
}
Reference: Debezium — MySQL schema history properties
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:
-
Connect, and determine the tables to capture.
-
Take a global read lock (
FLUSH TABLES WITH READ LOCK), which blocks writes from every client. -
Start a
REPEATABLE READtransaction with a consistent snapshot. -
Read the current binlog position and the structure of the tables.
-
With
snapshot.locking.mode=minimal, release the global lock. -
Read all rows of each table inside the transaction, and emit them as
op=revents. -
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 |
|---|---|
|
Global read lock only while schemas and the binlog position are read; then a |
|
Blocks all writes for the whole snapshot. Only for clients whose concurrent operations are incompatible with
|
|
No locks. Safe only if no schema change happens during the snapshot. |
|
A |
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 |
|---|---|
|
Snapshot when no offset exists, or when an earlier snapshot did not finish; then stream. |
|
Snapshot, then stop. |
|
Snapshot at every start. |
|
Capture only the schema, then stream. |
|
Rebuild a lost or corrupted schema history topic. |
|
Snapshot if there is no offset, or the stored binlog position or GTID is no longer on the server. |
|
Controlled by |
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.mode": "initial",
"snapshot.locking.mode": "minimal",
"snapshot.max.threads": "4",
"snapshot.fetch.size": "10000"
}
Reference: Debezium — snapshot.locking.mode
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.
-- 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.
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.
converters=boolean
boolean.type=io.debezium.connector.binlog.converters.TinyIntOneToBooleanConverter
boolean.selector=shop.customer.active
Reference: Debezium — TINYINT(1) to Boolean
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.
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=.*
Reference: Debezium — Zero-date fallback
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.
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
Reference: Debezium — JDBC sink data types
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 |
|---|---|---|
|
|
|
|
|
|
|
|
What to do with binlog events for tables missing from the in-memory schema ( |
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 |
|
|
Binlog file names in the examples |
|
|
Checking the binlog |
|
|
GTIDs |
Off by default; enable |
Enabled by default, no configuration needed. Format |
Original SQL in events ( |
|
|
New binlog format |
— |
MariaDB 11.4 and later: set |
Binlog compression |
— |
Not supported: |
InnoDB-based binlog |
— |
MariaDB 12.3 and later can store the binlog in InnoDB ( |
|
Default |
Default |
|
Available (defaults |
Not listed in the MariaDB properties. |
JMX MBean domain |
|
|
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-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
SHOW VARIABLES LIKE '%log_bin%';
SHOW GLOBAL VARIABLES WHERE variable_name IN
('binlog_format', 'binlog_row_image', 'binlog_legacy_event_pos', 'gtid_current_pos');
Reference: Debezium — MariaDB: Enabling the binlog
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]
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:
{
"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:
{ "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" } }
Reference: Debezium — MariaDB connector properties
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).
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 |
|---|---|
|
Where the connector is. Compare with |
|
Confirms GTID positioning, and the set the connector has processed. |
|
Events skipped (for example by |
|
Repeated binlog reconnects point to network or timeout problems. |
|
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.
SHOW BINARY LOGS; -- MySQL 8.4 and MariaDB
SELECT @@GLOBAL.gtid_executed; -- MySQL: GTIDs the server has executed
Reference: Debezium — MySQL streaming metrics
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 ( |
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 |
The schema history topic was deleted or compacted |
The connector cannot rebuild table structures and fails. |
Restore it, or use |
DDL that the parser cannot handle |
The connector stops. |
Try |
|
Incomplete |
Set |
MariaDB 11.4+ without |
After a restart, the connector may not find its resume point. |
Set |
The official sections, and recovery procedures that apply to all connectors, are on Troubleshooting & Failure Recovery and Offsets, Restarts & Exactly-Once.
Verification checklist
-
log_binis on,binlog_format=ROW,binlog_row_image=FULL,binlog_row_value_optionsis empty, and the server (or the replica the connector reads) has a uniqueserver-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, andLOCK TABLESwhere global read locks are not allowed. -
Each connector has a unique
database.server.idand 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 UNSIGNEDkeys andDATETIMEtime zones have a decision and, where needed, a converter. -
include.queryis off for tables with sensitive data. -
For MariaDB 11.4 and later:
binlog_legacy_event_pos=ONandlog_bin_compress=0.
References
-
Debezium — MySQL connector (stable) and 3.7
The lab (MySQL 8.4 and MariaDB 11.8 servers, the connector user, both connectors, the snapshot and the streaming
events) was run with Docker on 2026-11-09 against Debezium 3.7.1.Final and Kafka 4.3.1. The set-binlog-position
signal, the zero-date and JDBC-sink converters, the InnoDB-based binlog and the cloud settings are derived from the
official documentation and were not run.