Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySql returns wrong results for emoji strings

My database, tables, fields all are using utf8mb4. I can store well emoji symbols into some fields. Now I try to query such as:

SELECT * FROM user WHERE name='😀😇😈😉'

Amazing, the result are records with field names different such as '😀😃😇😉'

Looks like mysql matches emoji strings by their lengths but not contents.

Any idea to fix that problem? Many thanks.

like image 313
Tony Avatar asked Jun 05 '15 03:06

Tony


1 Answers

Just did this command to my table:

ALTER TABLE tablename CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;

that's all. the result is correct then.

like image 95
z33 Avatar answered Oct 15 '22 03:10

z33