How to store Emoji Character in MySQL Database

后端 未结 16 2291
迷失自我
迷失自我 2020-11-22 05:34

I am using Emoji character in my project. That characters are saved (??) into mysql database. I had used database Default collation in utf8mb4_general_ci. It sh

16条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 06:36

    Emoji support for application having tech stack - mysql, java, springboot, hibernate

    Apply below changes in mysql for unicode support.

    1. ALTER DATABASE CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
    2. ALTER TABLE CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

    DB Connection - jdbc url change:

    jdbc:mysql://localhost:3306/?useUnicode=yes&characterEncoding=UTF-8

    Note - If the above step is not working please update mysql-connector version to 8.0.15. (mysql 5.7 works with connector version 8.0.15 for unicode support)

提交回复
热议问题