How to store Emoji Character in My SQL Database

2019-01-01 03:48发布

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 show

1366 Incorrect string value: '\xF0\x9F\x98\x83\xF0\x9F...' for column 'comment' at row 1

标签: mysql
7条回答
步步皆殇っ
2楼-- · 2019-01-01 04:23

The main point hasn't been mentioned in the above answers that,

We need to pass query string with the options "useUnicode=yes" and "characterEncoding=UTF-8" in connection string

Something like this

mysql://USERNAME:PASSWORD@HOSTNAME:PORT/DATABASE_NAME?useUnicode=yes&characterEncoding=UTF-8
查看更多
登录 后发表回答