问题
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