mariadb-binlog

Generates correct mariadb-binlog commands for decoding, filtering, and replaying MariaDB binary logs.

28|115|Updated Jan 28, 2025
One-click install
npx skills add https://github.com/mariadb-corporation/mariadb-docs --skill mariadb-binlog-mariadb-corporation
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: mariadb-binlog
Source: https://github.com/mariadb-corporation/mariadb-docs/tree/main/agent-skills/granular/tools/mariadb-binlog
Command: npx skills add https://github.com/mariadb-corporation/mariadb-docs --skill mariadb-binlog-mariadb-corporation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Generated mariadb-binlog commands often contain subtle errors: treating commented pseudo-SQL as replayable statements, stripping the base64 BINLOG blob, using the removed --position flag, or replaying output back into a server without disabling binary logging. This Skill encodes the MariaDB-specific behaviors and traps so commands for reading, filtering, and replaying binary logs are correct. ## Core Features & Use Cases - Correct replay patterns: Pipe decoded output into the mariadb client (never execute via the tool itself), use --disable-log-bin when replaying onto the source server, and keep the default --base64-output=auto so output stays re-executable. - MariaDB-specific features: Covers ANNOTATE_ROWS_EVENT original-SQL comments (printed by default) and --flashback for generating reverse/undo SQL for DML, including its constraints (binlog_row_image=FULL, incompatible with --raw and -v/-vv). - Filtering guidance: Position, datetime, GTID, server-ID, and domain-ID filtering, plus the local-only and format-dependent behavior of --database and the -R requirement for remote reads. - Use Case: After an accidental table update, generate a flashback undo script with mariadb-binlog -d test -T mytable --start-datetime=... --flashback, review it, and apply it with the mariadb client. ## Quick Start Ask the AI to write a mariadb-binlog command that extracts events from a specific time window of a binary log file and safely replays them into the mariadb client.

Frequently Asked Questions about mariadb-binlog

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I replay a MariaDB binary log file?▼

Decode the binlog with mariadb-binlog and pipe the output into the mariadb client, for example: mariadb-binlog binlog.000001 | mariadb -u root -p. The tool only decodes and filters events; it never executes anything itself, so review the output before applying it to a live server.

How to generate undo SQL with mariadb-binlog flashback?▼

Use mariadb-binlog --flashback (-B) with a position or datetime range to emit the logical inverse of row events: INSERT becomes DELETE and UPDATE swaps before/after images. It works for DML only, requires binlog_row_image=FULL, and cannot be combined with --raw or -v/-vv.

Why is mariadb-binlog -v output not replayable?▼

The ###-prefixed pseudo-SQL lines produced by -v/-vv are comments for human readability only; the executable statement is the base64 BINLOG blob printed alongside them. Using --base64-output=decode-rows removes the blob entirely, making the output debugging-only.

Does mariadb-binlog show the original SQL for row events?▼

Yes, MariaDB writes a MariaDB-specific ANNOTATE_ROWS_EVENT carrying the original SQL before each row event when binlog_annotate_row_events is ON (the default), and mariadb-binlog prints these annotations by default. Suppress them with --skip-annotate-row-events.

Why does mariadb-binlog --database not filter remote binlogs?▼

The --database option is documented as local-log-only and is ignored entirely in --raw mode. Its behavior also differs by logging format: statement-based logging matches the default database, while row-based logging matches any table update in that database.

How do I read binary logs from a remote MariaDB server?▼

Use -R/--read-from-remote-server together with --host, --port, --user, and --password; other connection flags are silently ignored without -R. Options like --to-last-log, --stop-never, and --raw also require -R.