How to store Emoji Character in MySQL Database

后端 未结 16 2296
迷失自我
迷失自我 2020-11-22 05:34

I am using Emoji character in my project. That characters are saved (??) into mysql database. I had used database Default collation in utf8mb4_general_ci. It sh

16条回答
  •  天命终不由人
    2020-11-22 06:29

    If you use command line interface for inserting sql file to database.

    Be sure your table charset utf8mb4 and column collation utf8mb4_unicode_ci or utf8mb4_bin

    mysql -u root -p123456 my_database < profiles.sql
    

    ERROR 1366 (HY000) at line 1679: Incorrect string value: '\xF0\x9F\x98\x87\xF0\x9F...' for column 'note' at row 328

    we can solve the problem with this parameter --default-character-set=name (Set the default character set)

    mysql -u root -p123456 --default-character-set=utf8mb4 my_database < profiles.sql
    

提交回复
热议问题