|
本帖最后由 jiawang 于 2023-3-23 08:33 编辑
问题现象:
[root@sztech data]# mysqlbinlog binlog.index
mysqlbinlog: [ERROR] unknown variable 'default-character-set=utf8'
产生这个问题的原因是因为我在my.cnf中的client选项组中添加了:
default-character-set=utf8
这个是mysqlbinlog的一个bug
查看my.cnf参数文件
[root@sztech data]# cd /etc
[root@sztech etc]# more my.cnf
#[mysqld]
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
#[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /usr/local/mysql/mysql.sock
character-set-server=utf8
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
socket = /usr/local/mysql/mysql.sock
default-character-set=utf8
[root@sztech etc]#
解决方法有2个,1或者2都可以
1.修改配置文件
修改配置文件 /etc/my.cnf ,将default-character-set = utf8 改为 character-set-server = utf8,然后重启 MySQL 服务。
2.带上参数 --no-defaults
运行命令时带上参数 --no-defaults:
[root@sztech data]# mysqlbinlog --no-defaults --base64-output=decode-rows -v /usr/local/mysql/data/binlog.000003 --result-file=mysql0003.sql
[root@sztech data]# ll
total 168024
-rw-r-----. 1 mysql mysql 56 Oct 20 14:39 auto.cnf
-rw-r-----. 1 mysql mysql 470 Mar 20 11:23 binlog.000001
-rw-r-----. 1 mysql mysql 199 Mar 20 14:09 binlog.000002
-rw-r-----. 1 mysql mysql 199 Mar 20 14:12 binlog.000003
-rw-r-----. 1 mysql mysql 155 Mar 20 14:12 binlog.000004
-rw-r-----. 1 mysql mysql 64 Mar 20 14:12 binlog.index
-rw-------. 1 mysql mysql 1680 Oct 20 14:39 ca-key.pem
-rw-r--r--. 1 mysql mysql 1112 Oct 20 14:39 ca.pem
-rw-r--r--. 1 mysql mysql 1112 Oct 20 14:39 client-cert.pem
-rw-------. 1 mysql mysql 1676 Oct 20 14:39 client-key.pem
-rw-r-----. 1 mysql mysql 5927 Oct 20 14:39 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 Mar 20 11:23 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Mar 20 11:23 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Oct 20 14:39 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912 Mar 20 11:23 ibtmp1
drwxr-x---. 2 mysql mysql 143 Oct 20 14:39 mysql
-rw-r-----. 1 root root 669 Mar 23 08:26 mysql0003.sql
-rw-r-----. 1 mysql mysql 25165824 Mar 20 11:23 mysql.ibd
drwxr-x---. 2 mysql mysql 4096 Oct 20 14:39 performance_schema
-rw-------. 1 mysql mysql 1680 Oct 20 14:39 private_key.pem
-rw-r--r--. 1 mysql mysql 452 Oct 20 14:39 public_key.pem
-rw-r--r--. 1 mysql mysql 1112 Oct 20 14:39 server-cert.pem
-rw-------. 1 mysql mysql 1680 Oct 20 14:39 server-key.pem
drwxr-x---. 2 mysql mysql 28 Oct 20 14:39 sys
-rw-r-----. 1 mysql mysql 1510 Mar 20 11:23 sztech.err
-rw-r-----. 1 mysql mysql 527 Mar 23 08:22 sztech.log
-rw-r-----. 1 mysql mysql 5 Mar 20 11:23 sztech.pid
-rw-r-----. 1 mysql mysql 10485760 Mar 20 11:23 undo_001
-rw-r-----. 1 mysql mysql 10485760 Mar 20 11:23 undo_002
[root@sztech data]# more mysql0003.sql
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#230320 14:09:19 server id 1 end_log_pos 124 CRC32 0x3a014564 Start: binlog v 4, server v 8.0.11 created 230320 14:09:19
# at 124
#230320 14:09:19 server id 1 end_log_pos 155 CRC32 0xa2e9f2a4 Previous-GTIDs
# [empty]
# at 155
#230320 14:12:09 server id 1 end_log_pos 199 CRC32 0x30bc7c7d Rotate to binlog.000004 pos: 4
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
[root@sztech data]#
|
|