MySQL:开启bin log

来自WHY42
imported>Soleverlee2017年7月7日 (五) 07:08的版本
[mysqld]
log-bin=mysql-bin
server_id=1

mysql5.7以后要求必须填写server-id

mysql> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin       | ON    |
+---------------+-------+
1 row in set (0.01 sec)

mysql> show binary logs;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql-bin.000001 |       809 |
+------------------+-----------+
1 row in set (0.00 sec)

mysql> show binlog events in 'mysql-bin.000001';
+------------------+-----+----------------+-----------+-------------+------------------------------------------+
| Log_name         | Pos | Event_type     | Server_id | End_log_pos | Info                                     |
+------------------+-----+----------------+-----------+-------------+------------------------------------------+
| mysql-bin.000001 |   4 | Format_desc    |         1 |         123 | Server ver: 5.7.17-13-log, Binlog ver: 4 |
| mysql-bin.000001 | 123 | Previous_gtids |         1 |         154 |                                          |
| mysql-bin.000001 | 154 | Anonymous_Gtid |         1 |         219 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'     |
| mysql-bin.000001 | 219 | Query          |         1 |         293 | BEGIN                                    |
| mysql-bin.000001 | 293 | Table_map      |         1 |         362 | table_id: 296 (eve_db.eve_event)         |
| mysql-bin.000001 | 362 | Update_rows    |         1 |         461 | table_id: 296 flags: STMT_END_F          |
| mysql-bin.000001 | 461 | Xid            |         1 |         492 | COMMIT /* xid=129 */                     |
| mysql-bin.000001 | 492 | Anonymous_Gtid |         1 |         557 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'     |
| mysql-bin.000001 | 557 | Query          |         1 |         639 | BEGIN                                    |
| mysql-bin.000001 | 639 | Table_map      |         1 |         708 | table_id: 296 (eve_db.eve_event)         |
| mysql-bin.000001 | 708 | Write_rows     |         1 |         778 | table_id: 296 flags: STMT_END_F          |
| mysql-bin.000001 | 778 | Xid            |         1 |         809 | COMMIT /* xid=135 */                     |
+------------------+-----+----------------+-----------+-------------+------------------------------------------+
12 rows in set (0.00 sec)