Resolving the "Incorrect string value" Error in MySQL for Emoji Storage
When storing tweets containing emojis like "🎶," users may encounter an error stating "Incorrect string value..." This error is caused by incompatible character encodings.
To resolve this issue, the character sets of the database and the table where the tweets are stored need to be configured to support Unicode characters. Here are the steps to follow:
Modify the MySQL Configuration File:
Find the [mysqld] section and add or modify the following lines:
Change Database and Table Character Sets:
Connect to MySQL and run the following commands:
Verify the Changes:
Run the following command to confirm the character set and collation settings:
After making these changes, the MySQL database should be able to store tweets with emojis without encountering the "Incorrect string value" error.
The above is the detailed content of How to Fix the MySQL \'Incorrect string value\' Error When Storing Emojis?. For more information, please follow other related articles on the PHP Chinese website!