Problem: The Emoji expression is stored in 4 bytes, so the traditional MySQL utf-8 encoding can only be stored for a maximum of 3 bytes.
FIX: Modify MySQL (5.5.3 or above) encoded as UTF8MB4 to store the emoji table, and set the set names UTF8MB4 otherwise the program writes and reads garbled.
Requirements: MySQL 5.5.3 or more (online said), I did not test, I use MySQL 5.6 pro-test, can be stored.
To modify the MySQL code:
1. OS X System: http://www.cnblogs.com/chenshuo/p/4751855.html
2. Linux System: http://www.cnblogs.com/chenshuo/p/4743144.html
3. Windows Please google Baidu on its own.
Full table coding (lest forget later)
CREATE TABLE`User' (' UID 'varchar( -)CHARACTER SETUtf8 not NULL DEFAULT "', ' email 'varchar( +)CHARACTER SETUtf8DEFAULT NULL, ' username 'varchar( +)CHARACTER SET UTF8MB4 DEFAULT NULL, ' password 'varchar( +)CHARACTER SETUtf8DEFAULT NULL, ' token 'varchar( +)CHARACTER SETUtf8DEFAULT NULL, ' OpenID 'varchar( +)CHARACTER SETUtf8DEFAULT NULL, ' Avatar 'varchar( -)CHARACTER SETUtf8DEFAULT NULL, ' Teamid 'varchar(Ten)CHARACTER SETUtf8DEFAULT '0', ' position 'smallint(6)DEFAULT '0', ' main 'smallint(6)DEFAULT '1', ' Captain 'smallint(6)DEFAULT '0', ' numbers 'smallint(6)DEFAULT '0', ' height 'int( One)DEFAULT '0', ' weight 'int( One)DEFAULT '0', ` Level`smallint(6)DEFAULT '0', ' Gold 'int( One)DEFAULT '0', ' Points 'int( One)DEFAULT 'Ten', ' phone 'varchar( One)CHARACTER SETUtf8DEFAULT NULL, ' address 'varchar( +)CHARACTER SETUtf8DEFAULT NULL, ' state 'smallint(6)DEFAULT '0', ' follow 'int( One)DEFAULT '0', ' fans 'int( One)DEFAULT '0', ' Createtime 'timestamp NULL DEFAULT Current_timestamp, PRIMARY KEY(' uid ')) ENGINE=InnoDBDEFAULT charset=utf8mb4 Collate=utf8mb4_bin;
Let MySQL database support emoji emoticons