MySQL Expression store error problem

Source: Internet
Author: User

MySQL uses the Utf-8 character encoding, but when the mobile side uses the input method's expression and stores the database, an error occurs.

' \xf0\x9f\x92\x94 ' ...

The reason for this is that UTF-8 encoding cannot store emoji characters.

Steps to resolve:

    1. Change database encoding to UTF8MB4 and UTF8MB4_UNICODE_CI
    2. Change the table that requires the expression to be encoded as UTF8MB4 and UTF8MB4_UNICODE_CI
    3. The encoding for that field stored in the change table is UTF8MB4 and utf8mb4_unicode_ci
    4. Project database Connection properties resource file remove URL encoding parameters
      After the above operation, the expression can be stored in the database, but the problem is all become?? Garbled
    5. Modify the MySQL configuration file my.cnf (Windows is my.ini,linux to MY.CNF)
      MY.CNF generally in the etc/mysql/my.cnf position. When you find it, add the following three sections:
      [Client]

      Default-character-set = Utf8mb4

      [MySQL]

      Default-character-set = Utf8mb4

      [Mysqld]

      Character-set-client-handshake = FALSE

      Character-set-server = Utf8mb4

      Collation-server = Utf8mb4_unicode_ci

      init_connect= ' SET NAMES utf8mb4 '

    6. Restart the MySQL database and re-view the character set

      After 5, 62 steps, finally successfully store the expression, and the query display is also possible.

MySQL Expression store error problem

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.