1220 database data_error ai_generated partial

ERROR 1220 (HY000): 执行命令'SHOW BINARY LOGS'时出错:二进制日志文件'mysql-bin.000123'已损坏

ERROR 1220 (HY000): Error when executing command 'SHOW BINARY LOGS': binary log file 'mysql-bin.000123' is corrupted

ID: database/mysql-binary-log-corruption

其他格式: JSON · Markdown 中文 · English
72%修复率
84%置信度
1证据数
2024-11-01首次发现

版本兼容性

版本状态引入弃用备注
MySQL 8.0 active — — —
MySQL 8.4 active — — —
MySQL 9.0 active — — —
MariaDB 10.11 active — — —
MariaDB 11.4 active — — —

根因分析

MySQL二进制日志文件因磁盘故障、意外关闭或不完整写入而损坏,阻止了复制或日志检查。

English

MySQL binary log file is corrupted due to disk failure, unexpected shutdown, or incomplete write, preventing replication or log inspection.

generic

官方文档

https://dev.mysql.com/doc/refman/8.0/en/binary-log.html

解决方案

  1. Skip the corrupted binary log file on the replica by setting the next log position. Example: STOP SLAVE; CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000124', MASTER_LOG_POS=4; START SLAVE;
  2. If the corruption is isolated, use mysqlbinlog to extract events up to the corruption point: mysqlbinlog --stop-position=123456 mysql-bin.000123 > partial.sql; then apply the partial log to the replica.
  3. Purge the corrupted binary log file after ensuring all replicas have caught up: PURGE BINARY LOGS TO 'mysql-bin.000124'; Then reset the master log: RESET MASTER;

无效尝试

常见但无效的做法:

  1. Delete all binary log files and restart MySQL. 90% 失败

    This breaks replication if replicas rely on those logs; it also removes forensic evidence. Use PURGE BINARY LOGS instead.

  2. Ignore the corrupted log and continue without fixing replication. 95% 失败

    Replication will stall at the corrupted log file; the replica will not apply further changes until the issue is resolved.