由于表情保存的需求,数据库需要保存用户表情,下面把mysql数据库utf8修改成utf8mb4
MySQL 版本5.5.3+
查询select version();
mysql驱动不低于5.1.13
修改My.cnf
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
没有修改为utf8mb4的需要手动修改;
set collation-server='utf8mb4';
等
修改后结果
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
重启数据库就可以了
网友评论