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:
- Change database encoding to UTF8MB4 and UTF8MB4_UNICODE_CI
- Change the table that requires the expression to be encoded as UTF8MB4 and UTF8MB4_UNICODE_CI
- The encoding for that field stored in the change table is UTF8MB4 and utf8mb4_unicode_ci
- 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
- 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 '
- 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