How to store characters like 🚕🎉 in MySQL

Test script as below:

CREATE TABLE test ( title varchar(45) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; INSERT INTO test (title) value ('🎉🚕'); 

The answer says:

 1366 Incorrect string value: '\xF0\x9F\x8E\x89\xF0\x9F...' for column 'title' at row 1. 

I am trying to install CHARSET on utf8 , utf16 , gbk , but the answers are the same.

I do not know how to name these characters “🎉🚕” and type them using the keyboard. But they are different from "♥ ☆", which can be stored in utf8 encoding.

Thanks.

+6
source share
3 answers

You can have a column type like BINARY or VARBINARY.

0
source

your value is stored as binary so that you can change the data type of your title column as blob .

0
source

CHARACTER SET utf8mb4 required for Emoji and some Chinese characters. utf8 not enough.

0
source