mysql的binlog日誌,用於記錄數據庫的增、刪、改等修改操做,默認處於關閉狀態。使用binlog實現數據恢復的條件爲html
一、binlog日誌功能已開啓mysql
二、若binlog在數據庫建立一段時候後開啓,則實現恢復數據須要基於binlog開啓以後某一時刻的數據備份sql
三、binlog工做在Statement level(默認)模式,隔離級別爲 repeatable read 時,採用樂觀鎖併發插入數據,可能發生死鎖數據庫
樂觀鎖: insert into A併發
select a, b, c from dual.net
where exists(select 1 from dual where '...' = (select max(...) from A)) rest
錯誤信息:Deadlock found when trying to get lock; try restarting transaction日誌
隔離級別爲read committed 時,依然報錯:impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logginghtm
即使查詢和插入的數據範圍不重合(如不一樣客戶同時插入數據),依然如此;binlog工做在Mixed模式下不存在該狀況,具體緣由待研究blog
binlog的使用及數據恢復過程,可參考一下分享: