Solution to the problem that mysql cannot store special characters

When doing curd operation today, I found that a row of data could not be inserted, and an error was reported, SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xF0\x9F\x88\xB2\xE5\xB9... ' for column 'chat_name' at row 29

The general meaning is that the data in line 29 is invalid characters. So I checked the 29 rows of data and found:

There is indeed a special character.

Reason: There is no encoding of this special character under utf-8, so it cannot be saved.

Solution: Change the data table and data fields to utf8mb4

Data table modification character set

Data field modification character set

After the modification is completed, the data can be saved:

 

 

Guess you like

Origin blog.csdn.net/baidu_36095053/article/details/124847125