How to Enable Binary Log in Linux

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

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

Enable the binary log file manually

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

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




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

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


sudo nano /etc/mysql.cnf

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

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


4 thoughts on “How to Enable Binary Log in Linux

  1. in mariadb, the bin_log will not have .log extention, it will be .000001 .000002 (six digit suffix), how to configure sqlbak in order to read these bin_log files ? Because Mariadb will ignore any extention for bin_log in my.cnf.

    1. Hi prast,

      Yes, you are right, files with bin logs will have extension 00001, 00002, etc.

      If you specify /var/log/mysql/mysql-bin.log or / var / log / mysql / mysql-bin bin log files will be named mysql-bin.00001, mysql-bin.00002, etc.

      Therefore, you can choose any option.

  2. Hi, I’m getting the error “unknown command” when I try to run:

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

    Sqlbak is installed and a connection has been established.

Leave a Reply to Lennon Cancel reply

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