Background:
Because of the need to implement emoji expression comment function, so the database needs to support emoji expression storage
MySQL UTF8 encodes a character up to 3 bytes, but a emoji expression is 4 bytes, so UTF8 does not support storing emoji emoticons. But UTF8 's superset utf8mb4 a character can have up to 4 bytes, so it can support the storage of emoji expression. However, UTF8MB4 encoding is not supported before mysql5.5, so MySQL must be 5.5 and above
1. First modify the MySQL configuration file
1 [Mysqld] 2 Character-set-client-handshake = FALSE 3 character-set-server = Utf8mb4 4 collation-server = Utf8mb4_unicode_ci 5 init_connect= ' SET NAMES utf8mb4 ' 6 7 [MySQL] 8 DEFAULT-CHARACTER-SET=UTF8MB4 9 Ten [Client] DEFAULT-CHARACTER-SET=UTF8MB4
Lines 5th and 10 row 11 are subject to availability
2. Modify the database connection address (this is easy to ignore)
Url=jdbc:mysql://106.14.66.185:3306/db_yyzb?autoreconnect=true& Rewritebatchedstatements=true& Useunicode=true& Characterencoding=utf-8& Zerodatetimebehavior=converttonull
3. Finally, you can view the character set in MySQL
1 show variables like ' char% ';
MySQL support emoji emoticons upload