MySQL support emoji emoticons upload

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.