所以,今天我遇到了这个问题:
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)
的my.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
如何解决?
答案 0 :(得分:0)
解决方案很简单。你只需要这样做
Instr