Error
Error Code:
1381
MySQL Error 1381: Binary logging inactive
Description
Error 1381, 'You are not using binary logging', indicates that the MySQL server is not configured to write changes to binary log files. This error typically occurs when attempting operations that explicitly require binary logging, such as replication, point-in-time recovery, or specific `XA` transactions, but the server was started without this feature enabled.
Error Message
You are not using binary logging
Known Causes
3 known causesBinary Logging Not Configured
The `log_bin` parameter is missing, commented out, or explicitly disabled in the MySQL server's primary configuration file (`my.cnf` or `my.ini`).
Server Started Without `log-bin`
The MySQL server process was initiated from the command line or via a service script without the `--log-bin` option, or explicitly with `--skip-log-bin`, overriding configuration settings.
Insufficient Permissions or Path Issues
The MySQL user lacks write permissions to the directory specified for binary logs, or the configured path for `log_bin_basename` is invalid, preventing log file creation.
Solutions
3 solutions available1. Enable Binary Logging Temporarily for the Current Session easy
Activates binary logging only for the duration of the current MySQL connection.
1
Connect to your MySQL server.
2
Execute the following SQL command to enable binary logging for the current session. This is useful for operations that require binary logging but you don't want to permanently enable it.
SET GLOBAL log_bin = ON;
3
Perform the operation that requires binary logging.
4
Optionally, you can disable it for the current session if needed, though it will automatically be disabled when the session ends.
SET GLOBAL log_bin = OFF;
2. Enable Binary Logging Permanently by Modifying the MySQL Configuration File medium
Configures MySQL to start with binary logging enabled on every restart.
1
Locate your MySQL configuration file. Common locations include `/etc/my.cnf`, `/etc/mysql/my.cnf`, `/etc/mysql/mysql.conf.d/mysqld.cnf` (on Debian/Ubuntu), or within the MySQL data directory on Windows.
2
Open the configuration file with a text editor. You will likely need root or administrator privileges.
3
Find the `[mysqld]` section. If it doesn't exist, create it.
[mysqld]
4
Add or uncomment the following lines to enable binary logging. You can also specify a base name for the log files and the format.
log_bin = mysql-bin
binlog_format = ROW
5
Save the changes to the configuration file.
6
Restart the MySQL service for the changes to take effect.
sudo systemctl restart mysql
7
Verify that binary logging is enabled by connecting to MySQL and running `SHOW VARIABLES LIKE 'log_bin';` or `SHOW GLOBAL VARIABLES LIKE 'log_bin';` The value should be 'ON'.
SHOW GLOBAL VARIABLES LIKE 'log_bin';
3. Replicate or Use Features Requiring Binary Logging easy
Understand that this error indicates a feature requiring binary logging is being attempted, and binary logging needs to be enabled for it to work.
1
Identify the operation or feature you are trying to use that is triggering this error. Common examples include setting up replication, using point-in-time recovery, or certain `mysqldump` options.
2
If the operation is critical and requires binary logging, refer to the 'Enable Binary Logging Permanently' solution to configure it. This is the most robust approach if the feature will be used regularly.
3
If the operation is a one-time task or for testing, consider the 'Enable Binary Logging Temporarily' solution.