簡體   English   中英

mysqlbinlog:未知變量'default-character-set = utf8mb4'

[英]mysqlbinlog: unknown variable 'default-character-set=utf8mb4'

啟動 mysqlbinlog 時返回錯誤:

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

如何解決?

也許,它與 /etc/mysql/mariadb.conf.d/50-client.cnf 的內容有關,即:

[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]

服務器配置為:

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

將 default-character-set=utf8 行移到 my.cnf 文件的 [mysql] 或 [mysqld] 部分下方。 mysqlbinlog 讀取 [client] 下的變量,但不讀取 [mysql]。 您的命令行客戶端和/或瀏覽器讀取配置文件的 [client] AND [mysql] 部分。

順便說一句,如果您使用 --set-charset=charset_name (>5.0.23) 選項,mysqlbinlog 可以采用指定的字符集。

來源: https://forums.mysql.com/read.php?103,189835,192421#gms

字符集服務器 = utf8mb4
或者
mysqlbinlog --no-defaults mysql-bin.000001

另一種解決方案是在失敗選項中添加松散_前綴:

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

如果不支持該選項,松散前綴會強制命令行工具不拋出錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM