MySQL:开启bin log:修订间差异

来自WHY42
imported>Soleverlee
创建页面,内容为“<source lang="bash"> [mysqld] log-bin=mysql-bin server_id=1 </source> mysql5.7以后要求必须填写server-id <pre> mysql> show variables like 'log_bin'; +--------...”
 
Riguz留言 | 贡献
无编辑摘要
 
(未显示另一用户的1个中间版本)
第13行: 第13行:
+---------------+-------+
+---------------+-------+
1 row in set (0.01 sec)
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)
# to delete bin logs:
# purge binary logs to 'mysql-bin.000017';
</pre>
</pre>


[[Category:Database]]
[[Category:Database]]

2020年5月3日 (日) 14:25的最新版本

[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)

# to delete bin logs:
# purge binary logs to 'mysql-bin.000017';