{
  "schema_version": 2,
  "id": "integrate/redis-data-integration/data-pipelines/prepare-dbs/my-sql-mariadb",
  "title": "Prepare MySQL/MariaDB for RDI",
  "url": "https://redis.io/docs/latest/integrate/redis-data-integration/data-pipelines/prepare-dbs/my-sql-mariadb/",
  "summary": "Prepare MySQL and MariaDB databases to work with RDI",
  "aliases": [
    "/integrate/redis-data-integration/ingest/data-pipelines/prepare-dbs/my-sql-mariadb/",
    "/integrate/redis-data-integration/ingest/data-transformation/prepare-dbs/my-sql-mariadb/",
    "/integrate/redis-data-integration/ingest/installation/prepare-dbs/my-sql-mariadb/"
  ],
  "tags": [
    "docs",
    "integrate",
    "rs",
    "rdi"
  ],
  "last_updated": "2026-10-05T11:23:44+03:00",
  "page_type": "content",
  "content_hash": "4661a7d05771de73bd34bfeaf952956c0a21c355a7039b4fb7154d93f5e1f037",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "The following checklist summarizes the steps to prepare a MySQL or MariaDB\ndatabase for RDI, with links to the sections that explain the steps in\nfull detail. You may find it helpful to track your progress with the\nchecklist as you complete each step.\n\n[code example]"
    },
    {
      "id": "1-create-a-cdc-user",
      "title": "1. Create a CDC user",
      "role": "content",
      "text": "The Debezium connector needs a user account to connect to MySQL/MariaDB. This\nuser must have appropriate permissions on all databases where you want Debezium\nto capture changes.\n\nRun the [MySQL CLI client](https://dev.mysql.com/doc/refman/8.3/en/mysql.html)\nand then run the following commands:\n\n[code example]\n\n1.  <a id=\"create-the-cdc-user\"></a>\n    Create the CDC user:\n\n    [code example]\n\n1.  <a id=\"grant-the-user-the-necessary-permissions\"></a>\n    Grant the required permissions to the user:\n\n    [code example]\n\n1.  <a id=\"finalize-the-users-permissions\"></a>\n    Finalize the user's permissions:\n\n    [code example]"
    },
    {
      "id": "2-enable-the-binlog",
      "title": "2. Enable the binlog",
      "role": "content",
      "text": "You must enable binary logging for MySQL replication. The binary logs record transaction\nupdates so that replication tools can propagate changes. You will need administrator\nprivileges to do this.\n\nFirst, you should check whether the `log-bin` option is already set to `ON`, using\nthe following query:\n\n[code example]\n\nIf `log-bin` is `OFF` then add the following properties to your\nserver configuration file:\n\n[code example]\n\nFor MariaDB, also add the following server configuration settings:\n\n[code example]\n\nRDI doesn't support binary log compression, so you must set\n`log_bin_compress` to `0`. For MariaDB 11.4 and later, you must also set\n`binlog_legacy_event_pos` to `1` to prevent RDI collector crash loops after\nthe MariaDB server restarts.\n\nYou can run the query above again to check that `log-bin` is now `ON`.\n\n> [!NOTE]\n> If you are using [Amazon RDS for MySQL](https://aws.amazon.com/rds/mysql/) then\n> you must enable automated backups for your database before it can use binary logging.\n> If you don't enable automated backups first then the settings above will have no\n> effect.\n\n&nbsp;\n\n> [!NOTE]\n> If you are using [Google Cloud SQL for MySQL](https://cloud.google.com/sql/docs/mysql),\n> you enable binary logging and set `binlog_row_image` through Cloud SQL instead of the\n> server configuration file. See\n> [Prepare Google Cloud SQL for MySQL for RDI](https://redis.io/docs/latest/integrate/redis-data-integration/data-pipelines/prepare-dbs/gcp-cloud-sql-mysql)\n> for the full setup."
    },
    {
      "id": "3-enable-gtids",
      "title": "3. Enable GTIDs",
      "role": "content",
      "text": "*Global transaction identifiers (GTIDs)* uniquely identify the transactions that occur\non a server within a cluster. You don't strictly need to use them with a Debezium MySQL\nconnector, but you might find it helpful to enable them.\nUse GTIDs to simplify replication and to confirm that the primary and replica servers are\nconsistent.\n\nGTIDs are available in MySQL 5.6.5 and later. See the\n[MySQL documentation about GTIDs](https://dev.mysql.com/doc/refman/8.0/en/replication-options-gtids.html#option_mysqld_gtid-mode) for more information.\n\nFollow the steps below to enable GTIDs. You will need access to the MySQL configuration file\nto do this.\n\n[code example]\n\n1.  <a id=\"enable-gtid_mode\"></a>\n    Enable `gtid_mode`:\n\n    [code example]\n\n1.  <a id=\"enable-enforce_gtid_consistency\"></a>\n    Enable `enforce_gtid_consistency`:\n\n    [code example]\n\n1.  <a id=\"confirm-the-changes\"></a>\n    Confirm the changes:\n\n    [code example]"
    },
    {
      "id": "4-configure-session-timeouts",
      "title": "4. Configure session timeouts",
      "role": "content",
      "text": "RDI captures an initial *snapshot* of the source database when it begins\nthe CDC process (see the\n[architecture overview](https://redis.io/docs/latest/integrate/redis-data-integration/architecture#overview)\nfor more information). If your database is large then the connection could time out\nwhile RDI is reading the data for the snapshot. You can prevent this using the\n`interactive_timeout` and `wait_timeout` settings in your MySQL configuration file:\n\n[code example]"
    },
    {
      "id": "5-enable-query-log-events",
      "title": "5. Enable query log events",
      "role": "content",
      "text": "If you want to see the original SQL statement for each binlog event then you should\nenable `binlog_rows_query_log_events` (MySQL configuration) or\n`binlog_annotate_row_events` (MariaDB configuration):\n\n[code example]\n\nThis option is available in MySQL 5.6 and later."
    },
    {
      "id": "6-check-binlog_row_value_options",
      "title": "6. Check `binlog_row_value_options`",
      "role": "content",
      "text": "You should check the value of the `binlog_row_value_options` variable\nto ensure it is not set to `PARTIAL_JSON`. If it *is* set to\n`PARTIAL_JSON` then Debezium might not be able to see `UPDATE` events.\n\nCheck the current value of the variable with the following command:\n\n[code example]\n\nIf the value is `PARTIAL_JSON` then you should unset the variable:\n\n[code example]"
    },
    {
      "id": "7-connect-over-tls-or-mtls",
      "title": "7. Connect over TLS or mTLS",
      "role": "content",
      "text": "To connect to the source database over TLS, set the source's `CACERT` secret to the source CA\ncertificate. For mutual TLS, also set the source's `CERT` and `KEY` secrets. See\n[Set secrets](https://redis.io/docs/latest/integrate/redis-data-integration/data-pipelines/deploy#set-secrets)\nfor the full list of source database TLS and mTLS secrets.\n\nSelect the TLS mode in the source `advanced.source` section, for example:\n\n[code example]\n\nRDI builds the keystore that presents the client certificate to the source database from the\nsource's `CERT` and `KEY` secrets, and configures the collector to use it.\n\n> [!NOTE]\n> Do not set `database.ssl.keystore` or `database.ssl.keystore.password` yourself. RDI\n> manages the keystore, so these properties are not only unnecessary, they are rejected when you\n> deploy the pipeline."
    },
    {
      "id": "8-configuration-is-complete",
      "title": "8. Configuration is complete",
      "role": "content",
      "text": "After following the steps above, your MySQL/MariaDB database is ready\nfor Debezium to use."
    }
  ],
  "examples": [
    {
      "id": "overview-ex0",
      "language": "checklist {id=\"mysqlmariadblist\"}",
      "code": "- [ ] [Create a CDC user](#1-create-a-cdc-user)\n- [ ] [Enable the binlog](#2-enable-the-binlog)\n- [ ] [Enable GTIDs](#3-enable-gtids)\n- [ ] [Configure session timeouts](#4-configure-session-timeouts)\n- [ ] [Enable query log events](#5-enable-query-log-events)\n- [ ] [Check binlog_row_value_options](#6-check-binlog_row_value_options)\n- [ ] [Connect over TLS or mTLS](#7-connect-over-tls-or-mtls)",
      "section_id": "overview"
    },
    {
      "id": "1-create-a-cdc-user-ex0",
      "language": "checklist {id=\"mysqlmariadb-create-cdc-user\" nointeractive=\"true\" }",
      "code": "- [ ] [Create the CDC user](#create-the-cdc-user)\n- [ ] [Grant the user the necessary permissions](#grant-the-user-the-necessary-permissions)\n- [ ] [Finalize the user's permissions](#finalize-the-users-permissions)",
      "section_id": "1-create-a-cdc-user"
    },
    {
      "id": "1-create-a-cdc-user-ex1",
      "language": "sql",
      "code": "mysql> CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';",
      "section_id": "1-create-a-cdc-user"
    },
    {
      "id": "1-create-a-cdc-user-ex2",
      "language": "sql",
      "code": "# MySQL <v8.0\n    mysql> GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'user' IDENTIFIED BY 'password';\n\n    # MySQL v8.0 and above\n    mysql> GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'user'@'localhost';",
      "section_id": "1-create-a-cdc-user"
    },
    {
      "id": "1-create-a-cdc-user-ex3",
      "language": "sql",
      "code": "mysql> FLUSH PRIVILEGES;",
      "section_id": "1-create-a-cdc-user"
    },
    {
      "id": "2-enable-the-binlog-ex0",
      "language": "sql",
      "code": "// for MySql 5.x\nmysql> SELECT variable_value as \"BINARY LOGGING STATUS (log-bin) ::\"\nFROM information_schema.global_variables WHERE variable_name='log_bin';\n// for MySql 8.x\nmysql> SELECT variable_value as \"BINARY LOGGING STATUS (log-bin) ::\"\nFROM performance_schema.global_variables WHERE variable_name='log_bin';",
      "section_id": "2-enable-the-binlog"
    },
    {
      "id": "2-enable-the-binlog-ex1",
      "language": "plaintext",
      "code": "server-id         = 223344 # Querying variable is called server_id, e.g. SELECT variable_value FROM information_schema.global_variables WHERE variable_name='server_id';\nlog_bin                     = mysql-bin\nbinlog_format               = ROW\nbinlog_row_image            = FULL\nbinlog_expire_logs_seconds  = 864000",
      "section_id": "2-enable-the-binlog"
    },
    {
      "id": "2-enable-the-binlog-ex2",
      "language": "plaintext",
      "code": "log_bin_compress            = 0\n\n# Required for MariaDB 11.4 and later.\nbinlog_legacy_event_pos     = 1",
      "section_id": "2-enable-the-binlog"
    },
    {
      "id": "3-enable-gtids-ex0",
      "language": "checklist {id=\"mysqlmariadb-enable-gtids\" nointeractive=\"true\" }",
      "code": "- [ ] [Enable gtid_mode](#enable-gtid_mode)\n- [ ] [Enable enforce_gtid_consistency](#enable-enforce_gtid_consistency)\n- [ ] [Confirm the changes](#confirm-the-changes)",
      "section_id": "3-enable-gtids"
    },
    {
      "id": "3-enable-gtids-ex1",
      "language": "sql",
      "code": "mysql> gtid_mode=ON",
      "section_id": "3-enable-gtids"
    },
    {
      "id": "3-enable-gtids-ex2",
      "language": "sql",
      "code": "mysql> enforce_gtid_consistency=ON",
      "section_id": "3-enable-gtids"
    },
    {
      "id": "3-enable-gtids-ex3",
      "language": "sql",
      "code": "mysql> show global variables like '%GTID%';\n    \n    >>> Result:\n\n    +--------------------------+-------+\n    | Variable_name            | Value |\n    +--------------------------+-------+\n    | enforce_gtid_consistency | ON    |\n    | gtid_mode                | ON    |\n    +--------------------------+-------+",
      "section_id": "3-enable-gtids"
    },
    {
      "id": "4-configure-session-timeouts-ex0",
      "language": "plaintext",
      "code": "mysql> interactive_timeout=<duration-in-seconds>\nmysql> wait_timeout=<duration-in-seconds>",
      "section_id": "4-configure-session-timeouts"
    },
    {
      "id": "5-enable-query-log-events-ex0",
      "language": "plaintext",
      "code": "mysql> binlog_rows_query_log_events=ON\n\nmariadb> binlog_annotate_row_events=ON",
      "section_id": "5-enable-query-log-events"
    },
    {
      "id": "6-check-binlog_row_value_options-ex0",
      "language": "sql",
      "code": "mysql> show global variables where variable_name = 'binlog_row_value_options';\n\n>>> Result:\n\n+--------------------------+-------+\n| Variable_name            | Value |\n+--------------------------+-------+\n| binlog_row_value_options |       |\n+--------------------------+-------+",
      "section_id": "6-check-binlog_row_value_options"
    },
    {
      "id": "6-check-binlog_row_value_options-ex1",
      "language": "sql",
      "code": "mysql> set @@global.binlog_row_value_options=\"\" ;",
      "section_id": "6-check-binlog_row_value_options"
    },
    {
      "id": "7-connect-over-tls-or-mtls-ex0",
      "language": "yaml",
      "code": "advanced:\n  source:\n    database.ssl.mode: verify_ca",
      "section_id": "7-connect-over-tls-or-mtls"
    }
  ]
}
