Mariadb enable binary log
Last updated: May 16, 2022
In today's article, I will tell you how to enable binary log in MariaDB. The binary log contains a record of all changes to the databases, both data and structure, as well as how long it took to execute each statement. It consists of a set of binary log and index files. This means that statements such as CREATE , ALTER , INSERT , UPDATE , and DELETE will be logged, but statements that do not affect data, such as SELECT and SHOW, will not be logged.
- Check if binary logging is enabled.
- Create a directory for binary logs.
- Let's edit the configuration file.
- Extra options.
1. Check if binary logging is enabled.
Before we change anything in the settings, let's check the system variables that respond to logging. The main variable responsible for enabling the binary log is called log_bin.
mariadb> show variables like 'log_bin';
We see in the screenshot the value of the Value field is OFF, which means that binary logging is disabled.
2. Create a directory for binary logs.
In this step, we will create a directory for the binary logs. If you do not do this and simply enable binary logging, then the logs themselves will be created in the directory where the database itself is stored.
$. mkdir /binary_log
$. chown -R mysql:mysql /binary_log
3. Let's edit the configuration file.
Now it's the turn to configure the configuration file itself. The file is located by default at /etc/my.cnf.d/server.cnf
$. vim /etc/my.cnf.d/server.cnf
Save and restart the server.
5. Extra options.
There are a lot of additional binary log parameters, but I will not describe them in this article.
mariadb> show variables like '%bin%';
Thank you all, I hope my article was of some help to you.