简体   繁体   中英

mysqlbinlog: unknown variable 'default-character-set=utf8mb4'

When launching mysqlbinlog it returns an error:

root@utils # mysqlbinlog --start-datetime="2021-12-05 13:13:00"
mysqlbinlog: unknown variable 'default-character-set=utf8mb4'

How to fix it?

Maybe, it related to the contents of /etc/mysql/mariadb.conf.d/50-client.cnf which is:

[client]
# Default is Latin1, if you need UTF-8 set this (also in server section)
default-character-set = utf8mb4

# socket location
socket = /var/run/mysqld/mysqld.sock

# Example of client certificate usage
# ssl-cert=/etc/mysql/client-cert.pem
# ssl-key=/etc/mysql/client-key.pem
#
# Allow only TLS encrypted connections
# ssl-verify-server-cert=on

# This group is *never* read by mysql client library, though this
# /etc/mysql/mariadb.cnf.d/client.cnf file is not read by Oracle MySQL
# client anyway.
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]

The server configuration is:

Server version: 10.3.31-MariaDB-0ubuntu0.20.04.1-log Ubuntu 20.04

Move the default-character-set=utf8 line below the [mysql] or [mysqld] sections of your my.cnf file. mysqlbinlog reads variables under [client], but not [mysql]. Your command-line client and/or browser reads the [client] AND [mysql] sections of the config file.

BTW, mysqlbinlog can take a specified character set, if you use the --set-charset=charset_name (>5.0.23) option.

source: https://forums.mysql.com/read.php?103,189835,192421#msg-192421

character-set-server = utf8mb4
or
mysqlbinlog --no-defaults mysql-bin.000001

Another solution is to add the loose_ prefix to the failing option:

[client]
loose-default-character-set=utf8mb4

The loose prefix forces command line tools not to throw an error, if the option isn't supported.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM