How do you enable the mysql binlog?

To enable the binlog feature in MySQL, follow these steps:

  1. Open the MySQL configuration file my.cnf (or my.ini for Windows systems).
  2. To enable the binlog feature, add or modify the following parameters in the [mysqld] section:
  3. log_bin is set to mysql-bin, logs will expire after 10 days, and the server has an ID of 1.
  4. log_bin: set the name of the binlog file, can be customized, for example mysql-bin.
  5. Set the retention time for binlog files in days. Expired binlog files will be automatically deleted.
  6. server_id: set a unique server ID that serves as an identifier for replication and multi-master replication.
  7. Save and close the configuration file.
  8. Restart MySQL server to apply the configuration.

Next, the MySQL server will start generating binlog files and recording all write operations. You can use the following command to view the content of the binlog files:

mysqlbinlog mysql-bin.000001

One of them is named mysql-bin.000001, which is the name of the generated binlog file.

Leave a Reply 0

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


广告
Closing in 10 seconds
bannerAds