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

- **ID:** `database/mysql-binary-log-corruption`
- **Domain:** database
- **Category:** data_error
- **Error Code:** `1220`
- **Verification:** ai_generated
- **Fix Rate:** 72%

## Root Cause

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

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| MySQL 8.0 | active | — | — |
| MySQL 8.4 | active | — | — |
| MySQL 9.0 | active | — | — |
| MariaDB 10.11 | active | — | — |
| MariaDB 11.4 | active | — | — |

## Workarounds

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;** (70% success)
   ```
   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.** (75% success)
   ```
   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;** (80% success)
   ```
   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;
   ```

## Dead Ends

- **Delete all binary log files and restart MySQL.** — This breaks replication if replicas rely on those logs; it also removes forensic evidence. Use PURGE BINARY LOGS instead. (90% fail)
- **Ignore the corrupted log and continue without fixing replication.** — Replication will stall at the corrupted log file; the replica will not apply further changes until the issue is resolved. (95% fail)
