Binlog Introduction:
A binary log that records SQL statements that occur to or potentially change data, and is stored in a binary form on disk.
function:
MySQL functions like Oracle's archive logs, which can be used to view the history of a database's changes (all SQL operations at a specific point in time), incremental database backups and restores (incremental and point-in-time recovery), and MySQL replication.
Open:
Show variables like '%log_bin% '; To see if opening
Method One, modify the my.cnf parameter file, the method needs to restart
Log-bin=mysql-bin #打开日志 (host needs to open), this mysql-bin can also be customized, here can also add a path, such as:/home/www/mysql_bin_log/mysql-bin
method to turn off binary logging: Log-bin = mysql-bin comment out
Method Two, do not restart the modified binary log configuration, the method MySQL version needs more than 5.6
SET @ @global. log_bin=1|0?? (1 is on, 0 is off)
View:
# 可查看参数帮助mysqlbinlog??--no-defaults --help # 查看最后100行mysqlbinlog??--no-defaults --base64-output=decode-rows -vv mysql-bin.000001 |tail -100 # 根据position查找mysqlbinlog??--no-defaults --base64-output=decode-rows -vv mysql-bin.000001 |grep -A 20 ‘4939002‘ # 根据position恢复部分数据 也可根据时间点恢复mysqlbinlog??--no-defaults --start-position=204136360 --stop-position=204136499 mysql-bin.000006 | mysql -uroot -pyourpassword test
"MySQL" Mysqlbinlog related introduction