不知道怎麼了,今天使用mysqlbinlog這個命令查看數據庫的日誌文件,出現瞭如下報錯:
[root@Darren1 logs]# mysqlbinlog -vv --base64-output=decode-rows mysql-bin.000006
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#170415 1:28:13 server id 23306 end_log_pos 123 Start: binlog v 4, server v 5.7.16-log created 170415 1:28:13
# Warning: this binlog is either in use or was not closed properly.
ERROR: Error in Log_event::read_log_event(): 'Sanity check failed', data_len: 71, event_type: 35
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
通過查閱資料,有網友說可能是mysqlbinlog版本與數據庫服務版本不匹配,然後當我使用全路徑/usr/local/mysql/bin/mysqlbinlog查看日誌文件時不會報錯。
然後通過which命令查看mysqlbinlog這個命令位置時發現:
[root@Darren1 logs]# which mysqlbinlog
/usr/bin/mysqlbinlog
這個位置的mysqlbinlog確實不是我安裝的腳本位置,/usr/local/mysql/bin/目錄纔是我指定存放腳本工具的位置,那麼/usr/bin/mysqlbinlog這個是怎麼來的呢?初步判斷是不小心安裝rpm版本的mysql時候生成的。
那麼知道原因,問題就好解決了:
刪除/usr/bin/目錄下的所有mysql工具,同時配置一下環境變量:
[root@Darren1 bin]# rm -rf /usr/bin/mysql*
[root@Darren1 bin]#echo 'export PATH=$PATH:/usr/local/mysql/bin/'>>/etc/profile
[root@Darren1 bin]#source /etc/profile
[root@Darren1 logs]# which mysqlbinlog
/usr/local/mysql/bin/mysqlbinlog
這樣系統默認使用的就是對應版本的mysqlbinlog了。