【问题标题】:MySQL utf8mb4 unicode (Smiles)MySQL utf8mb4 unicode (微笑)
【发布时间】:2018-01-27 03:38:12
【问题描述】:

所以,今天我遇到了这个问题:

SQL 请求:

INSERT INTO `sample` (`lol`) VALUES ('????');

回复:

Error Code: 1366. Incorrect string value: '\xF0\x9F\x91\x88' for column 'lol' at row 1

排序规则:

mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
    +--------------------------+--------------------+
    | Variable_name            | Value              |
    +--------------------------+--------------------+
    | character_set_client     | utf8mb4            |
    | character_set_connection | utf8mb4            |
    | character_set_database   | utf8mb4            |
    | character_set_filesystem | binary             |
    | character_set_results    | utf8mb4            |
    | character_set_server     | utf8mb4            |
    | character_set_system     | utf8               |
    | collation_connection     | utf8mb4_unicode_ci |
    | collation_database       | utf8mb4_unicode_ci |
    | collation_server         | utf8mb4_unicode_ci |
    +--------------------------+--------------------+
    10 rows in set, 1 warning (0.00 sec)

我的.ini:

[client]
port=3306
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
character-set-client-handshake = FALSE
collation-server = utf8mb4_unicode_ci
character-set-server=utf8mb4

MySQL Workbench Screenshot

Database structure

如何解决?

【问题讨论】:

标签: mysql hibernate unicode utf8mb4


【解决方案1】:

解决方案很简单。你只需要做 SET NAMES 'utf8mb4'

【讨论】:

    猜你喜欢
    • 2017-03-27
    • 1970-01-01
    • 2020-11-23
    • 2015-04-16
    • 1970-01-01
    • 1970-01-01
    • 2017-11-19
    • 2014-02-26
    相关资源
    最近更新 更多