MySQL mysqlbinlog 访问mysql-bin日志出错
问题
mysqlbinlog -v -v --base64-output=decode-rows mysql-bin.000166 | less
error: error in log_event::read_log_event(): 'found invalid event in binary log', data_len: 111, event_type: 35 /*!50530 set @@session.pseudo_slave_mode=1*/; /*!40019 set @@session.max_insert_delayed_threads=0*/; /*!50003 set @old_completion_type=@@completion_type,completion_type=0*/; delimiter /*!*/; # at 4 #190408 18:15:19 server id 311948559 end_log_pos 123 crc32 0x56e12e5d start: binlog v 4, server v 5.7.21-log created 190408 18:15:19 # warning: this binlog is either in use or was not closed properly. binlog ' nx+rxa8p9zcsdwaaahsaaaabaaqans43ljixlwxvzwaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaezgnaagaegaebaqeegaaxwaegggaaaaicagcaaaacgokkioaejqa av0u4vy= '/*!*/; delimiter ; # end of log file rollback /* added by mysqlbinlog */; /*!50003 set completion_type=@old_completion_type*/; /*!50530 set @@session.pseudo_slave_mode=0*/;
查看当前使用的mysqlbinlog文件位置
which mysqlbinlog
/usr/bin/mysqlbinlogll /usr/bin/mysqlbinlog
-rwxr-xr-x 1 root root 3259000 6月 10 2014 /usr/bin/mysqlbinlog
该myqlbinlog在2014年就已经存在了,推测是该机器中自带的mariadb中的
版本信息
/usr/bin/mysqlbinlog --version
/usr/bin/mysqlbinlog ver 3.3 for linux at x86_64
/usr/bin/mysqlbinlog ver 3.3 for linux at x86_64
copyright (c) 2000, 2013, oracle, monty program ab and others.dumps a mysql binary log in a format usable for viewing or for piping to
the mysql command line client.
查看当前运行的mysqld进程basedir
ps -ef | grep defaults | grep 3308 | awk '{print $8}'
/opt/mysql/base/5.7.21/bin/mysqld
版本信息
/opt/mysql/base/5.7.21/bin/mysqlbinlog -v
/opt/mysql/base/5.7.21/bin/mysqlbinlog ver 3.4 for linux-glibc2.12 at x86_64
删除原可执行文件mysqlbinlog,重新建立软链接
rm -r /usr/bin/mysqlbinlog
rm:是否删除普通文件 "/usr/bin/mysqlbinlog"?yln -s /opt/mysql/base/5.7.21/bin/mysqlbinlog /usr/bin
可正常使用
mysqlbinlog -v -v --base64-output=decode-rows mysql-bin.000166 | less
/*!50530 set @@session.pseudo_slave_mode=1*/; /*!50003 set @old_completion_type=@@completion_type,completion_type=0*/; delimiter /*!*/; # at 4 #190408 18:15:19 server id 311948559 end_log_pos 123 crc32 0x56e12e5d start: binlog v 4, server v 5.7.21-log created 190408 18:15:19 # warning: this binlog is either in use or was not closed properly. # at 123
老版本mysql可执行文件却能正常运行
ll /usr/bin/mysql
-rwxr-xr-x 1 root root 3546584 6月 10 2014 /usr/bin/mysql
mysql --version
mysql ver 15.1 distrib 5.5.35-mariadb, for linux (x86_64) using readline 5.1
/opt/mysql/base/5.7.21/bin/mysql -uroot -p --socket=/datas/mysql/data/3308/mysqld.sock -e"select version()"
enter password:
+------------+
| version() |
+------------+
| 5.7.21-log |
+------------+
结论
出现 error: error in log_event::read_log_event(): 'found invalid event in binary log', data_len: 111, event_type: 35 错误是由于当前使用的myqlbinlog可执行文件的版本和正在运行的mysqld进程basedir中mysqlbinlog的版本不一致导致的(版本低不能正常读取高版本的mysqld产生的mysql-bin文件,产生的mysql-bin文件有event老版本的myqlbinlog不能正常读取)
低版本的mysql可执行文件能正常登陆高版本的mysqld
下一篇: OC反射原理(机制)
推荐阅读
-
MySQL mysqlbinlog 访问mysql-bin日志出错
-
mysql audit-访问日志记录_MySQL
-
[MySQLbinlog]彻底解析Mixed日志格式的binlog_MySQL
-
mysql 开发进阶篇系列 33 工具篇(mysqlbinlog日志管理工具)
-
Python 分析Nginx访问日志并保存到MySQL数据库实例
-
利用nginx访问日志如何记录mysql中的用户id详解
-
mysql日志信息查看与设置mysql-bin
-
Mysql的binlog日志与mysqlbinlog命令
-
apache访问日志access.log的解析以及如何将其导入mysql_MySQL
-
mysql audit-访问日志记录_MySQL