BigTows Asked:2020-10-14 02:43:14 +0800 CST2020-10-14 02:43:14 +0800 CST 2020-10-14 02:43:14 +0800 CST mariadb 编码 772 有一个“奇妙”的符号“🐉”。当您尝试将其插入表中时,结果是: ERROR 1300 (HY000): Invalid utf8mb4 character string: '\xF0\x9F\x90\x89' 需要什么编码? utf-8 1 个回答 Voted Best Answer vp_arth 2020-10-14T03:02:02+08:002020-10-14T03:02:02+08:00 我怀疑这是“客户端”的错误。 尝试: SET NAMES utf8mb4; MariaDB 不在手边,这是 mysql 的行为方式: mysql> describe Storage; +-------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+-------+ | p | varchar(255) | NO | PRI | NULL | | | val | longtext | NO | | NULL | | +-------+--------------+------+-----+---------+-------+ 2 rows in set (0,00 sec) mysql> INSERT INTO Storage VALUES('Dragon', '🐉'); ERROR 1366 (HY000): Incorrect string value: '\xF0\x9F\x90\x89' for column 'val' at row 1 mysql> SET Names utf8mb4; Query OK, 0 rows affected (0,00 sec) mysql> INSERT INTO Storage VALUES('Dragon', '🐉'); Query OK, 1 row affected (0,10 sec) mysql> UPDATE Storage SET p = '🐉'; Query OK, 1 row affected (0,20 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> SELECT * FROM Storage; +------+------+ | p | val | +------+------+ | 🐉 | 🐉 | +------+------+ 1 row in set (0,00 sec)
我怀疑这是“客户端”的错误。
尝试:
MariaDB 不在手边,这是 mysql 的行为方式: