| English | 简体中文 |
binlog-inspect is a Rust command-line tool and library for inspecting plaintext MySQL binary logs. It reads one event at a time as a stream, decodes events into a typed model decoupled from the underlying library (including tagged/anonymous GTIDs, previous_gtids, table maps and row images), and emits JSON Lines, text or CSV.
-; download HTTP(S) files with the optional remote feature.uuid:tag:gno), anonymous_gtid, previous_gtids, rotate, stop, rows_query, incident, intvar, partial_update_rows (before images with applied JSON diffs) and write/update/delete row events; named but undecoded events retain their type and raw_len.database.table, byte-offset ranges (--start-position/--stop-position), timestamp ranges (--start-datetime/--stop-datetime) and exact GTIDs (--include-gtid), with before/after row images.--stats prints one JSON summary (files, events, bytes, transactions, per-type and per-table counts, errors); --completions generates shell completion scripts.visit_events for consuming compressed-transaction children individually.--output is written atomically: mode 0600 on unix, and existing files are never overwritten.Install from crates.io (requires Rust 1.88 or newer — the MSRV is verified and CI-enforced; the project uses the Rust 2024 edition). Note: 0.5.0 is a breaking library release (structured parser errors, #[non_exhaustive] public enums); downstream code needs a wildcard arm for exhaustive matches:
cargo install binlog-inspect --locked
Or build and install from source:
cargo build --locked --release
# or install into ~/.cargo/bin
cargo install --path .
Run these commands from the project root; --locked uses the dependencies in Cargo.lock:
./target/release/binlog-inspect path/to/mysql-bin.000001
cat path/to/mysql-bin.000001 | ./target/release/binlog-inspect - --events xid
./target/release/binlog-inspect path/to/mysql-bin.000001 --events query,xid --format text
./target/release/binlog-inspect path/to/mysql-bin.000001 --table app.orders --format csv --output rows.csv
./target/release/binlog-inspect path/to/mysql-bin.000001 --stats
JSON Lines is written to standard output by default. See the usage guide for exit-code semantics; on a partial parse failure the output contains the successfully parsed prefix, so check the exit status. --output creates a new file and never overwrites an existing one. Output can contain business data and should be stored in a trusted location.
Enable the optional feature for remote downloads:
cargo run --locked --features remote -- --url https://example.com/mysql-bin.000001
Requires Rust 1.88 or newer (the MSRV is verified and enforced by a dedicated CI job); the project uses the Rust 2024 edition.
--stream-payload-events streams them as one JSONL line per inner event (opt-in, JSONL only); lines emitted before an error are kept (exit 3, or 1 under --strict), and --max-inner-events has no effect in that mode.partial_update_rows decodes the before image and applies the JSON-diff after image against it; a diff that cannot be applied is preserved as a loss-marking partial_json value with its diffs and the reason.NEWDECIMAL member or malformed column metadata. Opaque jsonb members render per the documented rules — decimals and date/time values as their text form, other opaque types as base64:type<id>:<data> strings.unknown; named types such as rand and user_var keep only the type and raw_len.--max-event-size (up to the 1 GiB inspection limit), and library callers with with_max_event_size.VAR_STRING and TYPED_ARRAY table-map columns produce an explicit unsupported-type error with the current dependency decoder.cargo clippy --locked --all-targets -- -D warnings
cargo clippy --locked --all-targets --no-default-features -- -D warnings
cargo test --locked
cargo test --locked --all-features
cargo build --locked --no-default-features
cargo build --locked --all-features