{
  "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/1.19.1/data-pipelines/prepare-dbs/my-sql-mariadb/",
  "summary": "Prepare MySQL and MariaDB databases to work with RDI",
  "content": "\nThe 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```checklist {id=\"mysqlmariadblist\"}\n- [ ] [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```\n\n## 1. Create a CDC user\n\nThe 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```checklist {id=\"mysqlmariadb-create-cdc-user\" nointeractive=\"true\" }\n- [ ] [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)\n```\n\n1.  \u003ca id=\"create-the-cdc-user\"\u003e\u003c/a\u003e\n    Create the CDC user:\n\n    ```sql\n    mysql\u003e CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';\n    ```\n\n1.  \u003ca id=\"grant-the-user-the-necessary-permissions\"\u003e\u003c/a\u003e\n    Grant the required permissions to the user:\n\n    ```sql\n    # MySQL \u003cv8.0\n    mysql\u003e GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'user' IDENTIFIED BY 'password';\n\n    # MySQL v8.0 and above\n    mysql\u003e GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'user'@'localhost';\n    ```\n\n1.  \u003ca id=\"finalize-the-users-permissions\"\u003e\u003c/a\u003e\n    Finalize the user's permissions:\n\n    ```sql\n    mysql\u003e FLUSH PRIVILEGES;\n    ```\n\n## 2. Enable the binlog\n\nYou 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```sql\n// for MySql 5.x\nmysql\u003e 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\u003e SELECT variable_value as \"BINARY LOGGING STATUS (log-bin) ::\"\nFROM performance_schema.global_variables WHERE variable_name='log_bin';\n```\n\nIf `log-bin` is `OFF` then add the following properties to your\nserver configuration file:\n\n```\nserver-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\n```\n\nFor MariaDB, also add the following server configuration settings:\n\n```\nlog_bin_compress            = 0\n\n# Required for MariaDB 11.4 and later.\nbinlog_legacy_event_pos     = 1\n```\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\u003e [!NOTE]\n\u003e If you are using [Amazon RDS for MySQL](https://aws.amazon.com/rds/mysql/) then\n\u003e you must enable automated backups for your database before it can use binary logging.\n\u003e If you don't enable automated backups first then the settings above will have no\n\u003e effect.\n\n## 3. Enable GTIDs\n\n*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```checklist {id=\"mysqlmariadb-enable-gtids\" nointeractive=\"true\" }\n- [ ] [Enable gtid_mode](#enable-gtid_mode)\n- [ ] [Enable enforce_gtid_consistency](#enable-enforce_gtid_consistency)\n- [ ] [Confirm the changes](#confirm-the-changes)\n```\n\n1.  \u003ca id=\"enable-gtid_mode\"\u003e\u003c/a\u003e\n    Enable `gtid_mode`:\n\n    ```sql\n    mysql\u003e gtid_mode=ON\n    ```\n\n1.  \u003ca id=\"enable-enforce_gtid_consistency\"\u003e\u003c/a\u003e\n    Enable `enforce_gtid_consistency`:\n\n    ```sql\n    mysql\u003e enforce_gtid_consistency=ON\n    ```\n\n1.  \u003ca id=\"confirm-the-changes\"\u003e\u003c/a\u003e\n    Confirm the changes:\n\n    ```sql\n    mysql\u003e show global variables like '%GTID%';\n    \n    \u003e\u003e\u003e Result:\n\n    +--------------------------+-------+\n    | Variable_name            | Value |\n    +--------------------------+-------+\n    | enforce_gtid_consistency | ON    |\n    | gtid_mode                | ON    |\n    +--------------------------+-------+\n    ```\n\n## 4. Configure session timeouts\n\nRDI 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/1.19.1/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```\nmysql\u003e interactive_timeout=\u003cduration-in-seconds\u003e\nmysql\u003e wait_timeout=\u003cduration-in-seconds\u003e\n```\n\n## 5. Enable query log events\n\nIf 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```\nmysql\u003e binlog_rows_query_log_events=ON\n\nmariadb\u003e binlog_annotate_row_events=ON\n```\n\nThis option is available in MySQL 5.6 and later.\n\n## 6. Check `binlog_row_value_options`\n\nYou 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```sql\nmysql\u003e show global variables where variable_name = 'binlog_row_value_options';\n\n\u003e\u003e\u003e Result:\n\n+--------------------------+-------+\n| Variable_name            | Value |\n+--------------------------+-------+\n| binlog_row_value_options |       |\n+--------------------------+-------+\n```\n\nIf the value is `PARTIAL_JSON` then you should unset the variable:\n\n```sql\nmysql\u003e set @@global.binlog_row_value_options=\"\" ;\n```\n\n## 7. Configuration is complete\n\nAfter following the steps above, your MySQL/MariaDB database is ready\nfor Debezium to use.\n",
  "tags": ["docs","integrate","rs","rdi"],
  "last_updated": "2026-09-19T17:55:58-07:00"
}
