我读了很多关于如何在MySQL中实现表情符号支持的文章,但没有什么不起作用。
的my.cnf:
[client]
default-character-set = utf8mb4
[mysqld]
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
character-set-client-handshake = FALSE
[mysql]
default-character-set = utf8mb4
试验:
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 |
+--------------------------+--------------------+
我已尝试过MyISAM和InnoDB。
这有什么问题?
答案 0 :(得分:5)
尝试:
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 5.7.11 |
+-----------+
1 row in set (0.00 sec)
mysql> SET NAMES utf8mb4;
Query OK, 0 rows affected (0.00 sec)
mysql> DROP TABLE IF EXISTS `tbl_test`;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE IF NOT EXISTS `tbl_test` (
-> `message` VARCHAR(100) DEFAULT NULL
-> ) DEFAULT CHARSET=utf8mb4;
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO `tbl_test` (`message`)
-> VALUES ('Hello ');
Query OK, 1 row affected (0.00 sec)
mysql> SELECT `message`
-> FROM `tbl_test`;
+------------+
| message |
+------------+
| Hello |
+------------+
1 row in set (0.00 sec)
请参阅db-fiddle。
<强>更新强>
使用Workbench 6.3社区: