为啥我的Mysql不能存储表情呢!!!!
va.sql.BatchUpdateException: Incorrect string value: '\xF0\x9D\x94\xB9+)...' for column 'title' at row 1
ALTER TABLE table_name CHANGE column_name VARCHAR(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
找到linux下的mysql位置
$ whereis mysql 找到位置
$ vi my.cnf 【这里有my.ini,如果只有my-default.ini,则复制一份并命名为my.ini】
[ ]
[ ]
default-character-set = utf8mb4
[ ]
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
[ ]
default-character-set = utf8mb4
$ service mysqld restart 重启服务即可
set character_set_database=utf8;
set character_set_server=utf8;
<property name="connectionInitSqls">
<list>
<value>set names utf8mb4</value>
</list>
</property>
List<String> list=new ArrayList<>(1);
list.add("set names utf8mb4");
druidDataSource.setConnectionInitSqls(list);
jdbc.url=jdbc:mysql://localhost:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=TRUE
更多的内容请访问:https://blog.breakpoint.vip/
喜欢就在看吧!!!