mysql存表情emoji

By | 2022-03-12

需要使用的编码为 utf8mb4

1.先使用下面的命令查看mysql的编码格式

SHOW VARIABLES WHERE Variable_name LIKE 'character_set_%%%%' OR Variable_name LIKE 'collation%%%%';

2.修改配置

[client]
default-character-set=utf8mb4

[mysql]
default-character-set=utf8mb4

[mysqld]
port=3306
#character_set_server=utf8mb4
character-set-client-handshake = FALSE
character-set-server=utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'

配置完mysql一定要重启