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
- ……
2. Turn on and off binlog
2.1. Check whether it is enabled
show global variables like 'log_bin%';
2.2. Configuration off
2.2.1. Modify configuration
Add in configuration file my.ini
or my.cnf
[mysqld] file skip-log-bin
.
- for windows
my.ini
, for linuxmy.cnf
- Windows default directory is
C:\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
- open binlog
3. Clean up binlog log files
-
Login to connect to mysql. slightly
-
Execute cleanup command
- Note that this command must be in the binlog enabled state to be valid
reset master;
- Clean up as shown below