+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin | OFF |
+---------------+-------+
1 row in set (0.00 sec)
此时并没有开启 ;
修改 /etc/my.cnf
log_bin #开启log-bin
server-id=1 #用于主从复制是的id号
binlog_do_db=test #二进制需要同步的数据库名
binlog_ignore_db=mysql #避免同步
mysql 用户配置,以免不必要的麻烦
保存退出 重启mysql服务
mysql> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin | ON |
+---------------+-------+
1 row in set (0.01 sec)
已开启开启二进制日志记录;
当对test库进行操作时,就会在二进制日志中记录
mysql> SHOW BINLOG EVENTSG
*************************** 1. row ***************************
Log_name: VM_225_102_centos-bin.000001
Pos: 4
Event_type: Format_desc
Server_id: 1
End_log_pos: 123
Info: Server ver: 5.7.11-log, Binlog ver: 4
*************************** 2. row ***************************
Log_name: VM_225_102_centos-bin.000001
Pos: 123
Event_type: Previous_gtids
Server_id: 1
End_log_pos: 154
Info:
2 rows in set (0.00 sec)