{
  "id": "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",
  "tags": [
    "docs",
    "integrate",
    "rs",
    "rdi"
  ],
  "last_updated": "2026-04-01T08:10:08-05:00",
  "page_type": "content",
  "content_hash": "b66ff5d02d0f26673411d7859342d90effa73dce8ad0526ec6f9b048650db8c0",
  "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\nYou can run the query above again to check that `log-bin` is now `ON`.\n\nIf you are using [Amazon RDS for MySQL](https://aws.amazon.com/rds/mysql/) then\nyou must enable automated backups for your database before it can use binary logging.\nIf you don't enable automated backups first then the settings above will have no\neffect."
    },
    {
      "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]()\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-configuration-is-complete",
      "title": "7. 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)",
      "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": "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"
    }
  ]
}
