Binary Logs for MariaDB Community Server 10.4

Overview

MariaDB Community Server 10.4 writes statements and transactions to its binary logs.

Reference material is available for MariaDB Community Server 10.4.

Purpose

The binary logs are intended for:

  • Replicating statements and transactions to replica nodes using MariaDB Replication

  • Performing point-in-time recovery (PITR)

  • Analyzing data changes with mariadb-binlog

Format

The binary log uses a binary format. The mariadb-binlog utility is capable of displaying the contents in a human-readable format.

The binary log supports row-based logging, statement-based logging, and a mixed mode. In the mixed mode, most statements are logged in statement-based format, while some "unsafe" statements are written in row-based format.

The binary log format is configured by the binlog_format system variable:

[mariadb]
log_bin = mariadb-bin
binlog_format = ROW

Location

By default, binary logging is disabled.

You can determine the binary log's file name and location by querying the log_bin_basename system variable:

SHOW GLOBAL VARIABLES
   LIKE 'log_bin_basename';

Configuration

Several aspects of the binary log are configurable.

Configure the Path

The path to the binary logs is configured by the log_bin option.

The option can be set in a configuration file:

[mariadb]
log_bin=mariadbd-bin

The binary logs will be created in the data directory defined by the datadir system variable.

The binary logs can be placed outside of the data directory by setting the log_bin option to the absolute path of the desired location:

[mariadb]
log_bin=/binary_logs/mariadbd-bin

If the log_bin option is set, but no value is provided, the prefix for the binary logs is set to HOSTNAME-bin, where HOSTNAME is the system's host name:

[mariadb]
# base name on the system's host name
log_bin

Configure the Format

The format used for the binary log is configured by the binlog_format system variable.

The system variable can be set in a configuration file:

[mariadb]
binlog_format=ROW