Mysql8 configures binlog log skip-log-bin, enables and disables binlog, and cleans up binlog log files

1. General description

  • binlog is binary log, binary log file, which records all DML operations of MySQL.
  • Through the binlog log, we can do data recovery, incremental backup, master-master replication and master-slave replication, etc.
  • Developers may not pay much attention to binlog, but it is very important for operation and maintenance or architecture personnel.
  • mysql8 enables binlog by default, which has a slight impact on performance.
  • The binlog file name defaults to
    • ${hostname}-bin.000001
    • ${hostname}-bin.000002
    • ${hostname}-bin.000003
    • ……
    • insert image description here

2. Turn on and off binlog

2.1. Check whether it is enabled

show global variables like 'log_bin%';

insert image description here

2.2. Configuration off

2.2.1. Modify configuration

Add in configuration file my.inior my.cnf[mysqld] file skip-log-bin.
insert image description here

  • for windows my.ini, for linuxmy.cnf
  • Windows default directory isC:\ProgramData\MySQL\MySQL Server 8.0\my.ini

2.2.2. Restart mysql service

Windows, linux, and docker each have their own restart methods. slightly

2.3. Performance test

Insert 1 million entries into the user table

  • binlog not enabled
    insert image description here
  • open binlog
    insert image description here

3. Clean up binlog log files

  1. Login to connect to mysql. slightly

  2. Execute cleanup command

    • Note that this command must be in the binlog enabled state to be valid
reset master;
  1. Clean up as shown below
    insert image description here

Guess you like

Origin blog.csdn.net/lishuoboy/article/details/132125384
Recommended