MySQL mysqlbinlog access mysql-bin log error

Keywords: MySQL mysqlbinlog Session Linux

problem

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*/;

View the location of the mysqlbinlog file currently in use

which mysqlbinlog
/usr/bin/mysqlbinlog

ll /usr/bin/mysqlbinlog
-rwxr-xr-x 1 root root 3259000 6 Month 102014 /usr/bin/mysqlbinlog
this myqlbinlog It already exists in 2014 and presumably comes with the machine. mariadb Medium

Version information

/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.

View the currently running mysqld process basedir

ps -ef | grep defaults | grep 3308 | awk '{print $8}'
/opt/mysql/base/5.7.21/bin/mysqld

Version information

/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

Delete the original executable mysqlbinlog and re-establish the soft link

rm -r /usr/bin/mysqlbinlog
rm: Whether to Delete Ordinary Files "/usr/bin/mysqlbinlog"?y

ln -s /opt/mysql/base/5.7.21/bin/mysqlbinlog /usr/bin

It can be used normally.

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

The old version of mysql executable file can run normally

ll /usr/bin/mysql
-rwxr-xr-x 1 root root 3546584 6 Month 102014 /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 |
+------------+

conclusion

  • ERROR: Error in Log_event:: read_log_event():'Found invalid event in binary log', data_len: 111, event_type: 35 error is caused by the inconsistency between the current version of myqlbinlog executable file and the version of MySQL bin log in the running mysqld process basedir (low version can not normally read the mysql-bin file produced by high version of mysqld, resulting in mysql-bin file L-bin file with old version of event myqlbinlog cannot be read properly)

  • The low version of mysql executable can login to the high version of mysqld normally

Posted by Toshiba23 on Wed, 10 Apr 2019 10:00:32 -0700