O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Enabling binary logs

  1. Enable binary logging and set the server_id. Open the MySQL config file in your favorite editor and append the following lines. Choose server_id such that it will be unique to each MySQL server in your infrastructure. You can also simply put the log_bin variable in my.cnf without any value. In that case, the binary log is created in the data directory directory and uses hostname as its name.
shell> sudo vi /etc/my.cnf[mysqld]log_bin = /data/mysql/binlogs/server1server_id = 100
  1. Restart the MySQL server:
shell> sudo systemctl restart mysql
  1. Verify that binary logs are created:
mysql> SHOW VARIABLES LIKE 'log_bin%';+---------------------------------+-----------------------------------+| Variable_name                   | Value                             |+---------------------------------+-----------------------------------+ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required