Mysql database cannot save expression packs and complex Chinese characters

Can mysql database store emojis and complex Chinese characters?

The answer is no! Databases are perfectly fine for storage.

So why does the database report an error when I save it?

        The reason is that before mysql8.0, for the efficiency of mysql execution, the default character encoding is utf8, and its maximum character is 3, while the emoticon package is 4, so it cannot be stored. You only need to modify the character encoding of the field to utf8mb4 to save it , if there is still a problem, then you can look at the encoding format in the database connection configuration of the code, and change it to utf8mb4.

        By the way, utf8mb4 is an encoding format with a maximum character length of 4 (most bytes 4), added after 5.5.3, utf8 can be understood as a subset of it, also called utf8mb3, utf8mb4 is compatible with utf8, after mysql8.0 , MySql default encoding has changed to utf8mb4.

Guess you like

Origin blog.csdn.net/a2285786446/article/details/128969874