mysql中emoji表情存储
mysql中emoji表情存储 背景 在mysql 5.7.19,创建的数据库默认选择的编码是 utf8 -- UTF-8 Unicode ,因此字段默认的编码为 utf-8 ,但在项目开发中存在一个需求:在某个字段中存储混有emoji表情的字符串,此时以普通编码格式如 utf8 来存储emoji表情时,会报 org.springframework.orm.jpa.JpaSystemException: could not execute statement; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement ... Caused by: org.hibernate.exception.GenericJDBCException: could not execute statement ... Caused by: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x95\xE2\x80...' for column 'android_id' at row 1 请求的实例 解决方案 把 android_id 这个字段的编码格式改为: utf8mb4 ,如在Navicat中修改: