This page describes how to configure change data capture (CDC) to stream data from a self-managed MySQL database to a supported destination, such as BigQuery or Cloud Storage. These instructions also work for databases such as MariaDB, Percona Server for MySQL or Alibaba Cloud PolarDB.
Verify the configuration and retention period of the binary log
Confirm that the binary log is configured correctly by entering the following MySQL command:
SHOW GLOBAL VARIABLES LIKE '%binlog_format%';
Verify that the value for the
binlog_format
variable is set toROW
. Datastream doesn't supportMIXED
orSTATEMENT
binary log formats.Confirm that the row format for the binary log is set to
FULL
by entering the following MySQL command:SHOW GLOBAL VARIABLES LIKE 'binlog_row_image';
Verify that the replica updates option for the binary log is set to
ON
by entering the following MySQL command:SHOW GLOBAL VARIABLES LIKE 'log_replica_updates';
For MySQL versions earlier than 8.0.26, enter the following command instead:
SHOW GLOBAL VARIABLES LIKE 'log_slave_updates';
Verify that the retention period of the binary log is set to
604800
seconds (7
days) by entering the following MySQL command:SHOW GLOBAL VARIABLES LIKE 'binlog_expire_logs_seconds';
For MySQL versions earlier than 8.0.3, enter the following command instead:
SHOW GLOBAL VARIABLES LIKE 'expire_logs_days';
Create a Datastream user
To create a Datastream user, enter the following MySQL commands:
CREATE USER 'datastream'@'%' IDENTIFIED BY 'YOUR_PASSWORD'; GRANT REPLICATION SLAVE, SELECT, REPLICATION CLIENT ON *.* TO 'datastream'@'%'; FLUSH PRIVILEGES;
What's next
- Learn more about how Datastream works with MySQL sources.