MariaDB utf8mb4编码不正确的字符串值错误

时间:2019-06-21 09:46:06

标签: mysql mariadb mysql-workbench utf8mb4

我将数据库和表字符集更改为utf8mb4,并在MariaDB上将排序规则为utf8bm4_turkish_ci,以支持表情符号。虽然我可以通过终端连接到服务器来轻松地进行插入和选择操作,但是当我想通过客户端(Web应用程序或MySQL工作台)执行插入操作时,却出现“字符串值不正确”错误。另外,当我想使用select显示数据时,它已损坏。同时,我注意到了另一种情况。即使数据库和表不支持utf8mb4(我仅使用utf8进行测试),我也可以通过终端插入表情符号,甚至可以通过select查看它。

Insert and Select operation through terminal

Insert and Select operation through MySQL Workbench

my.cnf文件上的定义如下;

[mysqld]
datadir        = /var/lib/mysql
socket         = /var/lib/mysql/mysql.sock
user           = mysql
symbolic-links = 0
old_passwords  = 0

innodb_file_format        = Barracuda
default-storage-engine    = InnoDB
innodb_file_per_table     = 1
innodb_open_files         = 500
innodb_thread_concurrency = 24
lower_case_table_names    = 1
character-set-server      = utf8mb4
collation-server          = utf8mb4_turkish_ci
init-connect              = 'SET NAMES utf8mb4 COLLATE utf8mb4_turkish_ci'

skip-character-set-client-handshake
innodb_large_prefix

[client]
default-character-set = utf8mb4

[mysql]
skip-secure-auth
default-character-set = utf8mb4

1 个答案:

答案 0 :(得分:0)

此外,表中的列必须为CHARACTER SET utf8mb4。请提供SHOW CREATE TABLE,以便我们进行检查。

另外,从失败的客户端执行SHOW VARIABLES LIKE 'char%';;那里可能是错的。