How can I insert smiley faces into MySQL ( )
I’ve recently written a detailed guide on how to switch from MySQL’s utf8
to utf8mb4
. If you follow the steps there, everything should work correctly. Here are direct links to each individual step in the process:
- Step 1: Create a backup
- Step 2: Upgrade the MySQL server
- Step 3: Modify databases, tables, and columns
- Step 4: Check the maximum length of columns and index keys
- Step 5: Modify connection, client, and server character sets
- Step 6: Repair and optimize all tables
I suspect that your problem can be solved by following step 5. Hope this helps!
Do the Following things:
Set the database charset to utf8mb4
Set the charset of column to utf8mb4
like below query:
ALTER TABLE `comments` CHANGE `text` `text` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;