MySQL的二進(jìn)制日志(binary log)是一個(gè)二進(jìn)制文件,主要用于記錄修改數(shù)據(jù)或有可能引起數(shù)據(jù)變更的MySQL語句。二進(jìn)制日志(binary log)中記錄了對MySQL數(shù)據(jù)庫執(zhí)行更改的所有操作,并且記錄了語句發(fā)生時(shí)間、執(zhí)行時(shí)長、操作數(shù)據(jù)等其它額外信息,但是它不記錄SELECT、SHOW等那些不修改數(shù)據(jù)的SQL語句。二進(jìn)制日志(binary log)主要用于數(shù)據(jù)庫恢復(fù)和主從復(fù)制,以及審計(jì)(audit)操作。
官方文檔關(guān)于二進(jìn)制日志(binary log)的介紹如下:
The binary log contains “events” that describe database changes such as table creation operations or changes to table data. It also contains events for statements that potentially could have made changes (for example, a DELETE which matched no rows), unless row-based logging is used. The binary log also contains information about how long each statement took that updated data. The binary log has two important purposes:
· For replication, the binary log on a master replication server provides a record of the data changes to be sent to slave servers. The master server sends the events contained in its binary log to its slaves, which execute those events to make the same data changes that were made on the master. See Section 17.2, “Replication Implementation”.