创建数据库时配置
character set为:utf8mb4
collation为:utf8mb4_unicode_ci
表的配置
character set为:utf8mb4
collation为:utf8mb4_general_ci
插入表情(例如?)时候报错
java.sql.SQLException: Incorrect string value: '\xF0\x9F\x94\xA50+...'
执行show variables like 'character%' ;
character_set_client utf8mb4
character_set_connection utf8mb4
character_set_database utf8mb4
character_set_filesystem binary
character_set_server utf8
character_set_system utf8
原因是mysql客户端配置的字符集是utf8,修改mysql的配置文件
character_set_server=utf8mb4
重启mysql
执行show variables like 'character%' ;
character_set_client utf8mb4
character_set_connection utf8mb4
character_set_database utf8mb4
character_set_filesystem binary
character_set_server utf8mb4
character_set_system utf8
版权声明:本文为qq_35001776原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。