How to Enable Binary Log in Linux

Below is a short tutorial on how to enable binary log in Linux.

  1. Locate the configuration file of MySQL Server my.cnf or mysql.cnf

As a rule, this file is located along the path:

/etc/mysql.cnf 

or

/etc/my.cnf

If you cannot find it, please use the following command:

sudo find / -type f -name mysql.cnf
  1. Edit the configuration file of MySQL

Run:

sudo nano /etc/mysql.cnf

and add the following text to the end of the file:

[mysqld] 
server-id        = 1
expire_logs_days = 10
binlog_format    = row
log_bin          = /var/log/mysql/mysql-bin.log
  1. Restart MySQL Server
sudo service mysql restart

 

Enable the binary log file via SqlBak

If SqlBak is installed on your server and a connection is established to your MySQL Server, then you can enable binary logs via one command:

sudo sqlbak —configure-mysql —connection-id=1 

If you have set several connections, then in the –connection-id parameter, you have to specify the connection ID to the database for which you want to enable binary logs. To find the connection ID, use the following command:

sudo sqlbak -sc

Leave a Reply

Your email address will not be published. Required fields are marked *