inno binlog

Parse and analyze MySQL binary log files.

Usage

# Text summary
inno binlog -f mysql-bin.000001

# JSON output
inno binlog -f mysql-bin.000001 --json

# Limit event listing
inno binlog -f mysql-bin.000001 -l 100

# Filter by event type
inno binlog -f mysql-bin.000001 --filter-type TABLE_MAP

# Verbose (show column types)
inno binlog -f mysql-bin.000001 -v

Options

OptionDescription
-f, --filePath to MySQL binary log file
-l, --limitMaximum number of events to display
--filter-typeFilter events by type name (e.g. TABLE_MAP, WRITE_ROWS)
-v, --verboseShow additional detail (column types for TABLE_MAP events)
--jsonOutput in JSON format

Output

Text Mode

Text output shows:

  1. Format Description — server version, binlog version, creation timestamp, checksum algorithm.

  2. Event Type Distribution — counts per event type, sorted by frequency.

  3. Table Maps — databases and tables referenced in TABLE_MAP events with column counts.

  4. Event Listing — chronological event table with offset, type, timestamp, server ID, and event length.

JSON Mode

Returns a structured BinlogAnalysis object:

{
  "format_description": {
    "binlog_version": 4,
    "server_version": "8.0.35",
    "create_timestamp": 1700000000,
    "header_length": 19,
    "checksum_alg": 1
  },
  "event_count": 1542,
  "event_type_counts": {
    "TABLE_MAP_EVENT": 200,
    "WRITE_ROWS_EVENT_V2": 180,
    "QUERY_EVENT": 150
  },
  "table_maps": [
    {
      "table_id": 108,
      "database_name": "mydb",
      "table_name": "users",
      "column_count": 5,
      "column_types": [3, 15, 15, 12, 3]
    }
  ],
  "events": [...]
}

Event Types

The parser recognizes all standard MySQL binary log event types (0-40+). Key event types:

Type CodeNameDescription
2QUERY_EVENTSQL statement (DDL or statement-based DML)
15FORMAT_DESCRIPTION_EVENTBinlog file header metadata
16XID_EVENTTransaction commit marker
19TABLE_MAP_EVENTTable schema mapping for row events
30WRITE_ROWS_EVENT_V2Row-based INSERT data
31UPDATE_ROWS_EVENT_V2Row-based UPDATE data (before/after)
32DELETE_ROWS_EVENT_V2Row-based DELETE data
33GTID_LOG_EVENTGlobal Transaction ID

Background

MySQL binary logs record all data-modifying operations for replication and point-in-time recovery. Binary log files start with a 4-byte magic number (\xfe\x62\x69\x6e) followed by a FORMAT_DESCRIPTION_EVENT, then a sequence of events.

The inno binlog subcommand reads the file header, validates the magic bytes, parses the format description, then streams through all events to produce type distribution statistics and a detailed event listing. Row-based events are parsed to extract table mappings and row counts.

Binary log files use little-endian byte order, unlike InnoDB tablespace files which use big-endian.