Storing emojis in MySQL database

别说谁变了你拦得住时间么 提交于 2021-02-08 15:07:41

问题


I'm using Spring boot and I can't store emojis in database. I don't have access to my.cnf file. What I've done so far is:

ALTER DATABASE name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

For each table:
ALTER TABLE table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

For each column:
ALTER TABLE table CHANGE column column VARCHAR(190) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

In application.properties file I'm using this:

spring.datasource.url = jdbc:mysql://server/database?useUnicode=yes&characterEncoding=UTF-8

And now, when I'm using Postman to send anything with emoji, I see two question marks (??) in database instead emoji. But when I've added something with emoji using phpmyadmin - I see emojis.

来源:https://stackoverflow.com/questions/43629756/storing-emojis-in-mysql-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!