MySQL binlog_format and binlog_row_image explained▾

Learn

MySQL binlog_format and binlog_row_image explained

What MySQL's binlog_format (ROW, STATEMENT, MIXED) and binlog_row_image (FULL, MINIMAL, NOBLOB) settings do, which values CDC needs, and how to check them.

MySQL's binary log records changes for replication and point-in-time recovery. Two settings decide what each entry contains, and change data capture needs specific values.

binlog_format

  • STATEMENT logs the SQL statement, for example UPDATE orders SET status = 'paid' WHERE id = 7. The resulting row values aren't recorded, so a CDC tool can't know them.
  • ROW logs the actual before and after values of every changed row. This is what CDC requires, and it is the default in MySQL 8.
  • MIXED uses statements most of the time and rows only in some cases, so it isn't reliable for CDC.

binlog_row_image

  • FULL (default) logs every column of the row. Required, so each change in BigQuery is complete.
  • MINIMAL logs only the changed columns and the key, so the other columns would be missing.
  • NOBLOB omits unchanged BLOB and TEXT columns.

Check your settings

SHOW VARIABLES WHERE Variable_name IN
  ('log_bin', 'binlog_format', 'binlog_row_image', 'binlog_expire_logs_seconds');

You want log_bin = ON, binlog_format = ROW, binlog_row_image = FULL, and logs kept for at least a day. Each host sets these differently; see setup by host.