1. Error reporting details
fail to open MySQL connection: [CDC:ErrMySQLConnectionError]Error 1298: Unknown or incorrect time zone: 'Asia/Shanghai'
2. Troubleshooting
# Login tidb and check the time zone
show variables like '%time_zone%';
+------------------+---------------+
| Variable_name | Value |
+------------------+---------------+
| system_time_zone | Asia/Shanghai |
| time_zone | SYSTEM |
+------------------+---------------+
# login mysql and check the time zone
show variables like '%time_zone%';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | CST |
| time_zone | SYSTEM |
+------------------+--------+
It can be found that the time zone of the upstream tidb is North America/USA, while the time zone of the downstream MySQL is CST
3. Solution
Method 1: load the time zone
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql -p
Method 2: write sink to upstream and downstream time zones
cdc cli changefeed create --sink-uri="mysql://user:password@mysql_ip:mysql_port/?time-zone=CST" --pd=http://pd_ip:pd_port