美文网首页
Mysql开启binlog

Mysql开启binlog

作者: hynial | 来源:发表于2020-05-07 23:00 被阅读0次

配置my.cnf:

[mysqld]
server-id=1
log-bin=mysql-bin
expire-logs-days=1

default-time-zone='+08:00'
skip-host-cache
skip-name-resolve

or

set sql_log_bin=1;

查看binlog开启状态:

show binary logs;
show master status;
show variables like '%log_bin%';

常见错误:

BINLOG statement can no longer be used to apply query events

fix:

$ head -n 11 binlogs.sql | cat -n
     1  /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
     2  /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
     3  DELIMITER /*!*/;
     4  # at 4
     5  #170128 17:58:11 server id 1  end_log_pos 123 CRC32 0xccda074a  Start: binlog v 4, server v 5.7.16-9-debug-log created 170128 17:58:11 at startup
     6  ROLLBACK/*!*/;
     7  BINLOG '
     8  g7GMWA8BAAAAdwAAAHsAAAAAAAQANS43LjE2LTktZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA
     9  AAAAAAAAAAAAAAAAAACDsYxYEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA
    10  AUoH2sw=
    11  '/*!*/;

ref:

https://www.percona.com/blog/2017/02/16/mysql-bug-72804-workaround-binlog-statement-can-no-longer-be-used-to-apply-query-events/

数据恢复:
https://dev.mysql.com/doc/refman/8.0/en/point-in-time-recovery.html

相关文章

网友评论

      本文标题:Mysql开启binlog

      本文链接:https://www.haomeiwen.com/subject/wcgzghtx.html