且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将表情符号(UTF8 4字节字符)插入MySQL< 5.5

更新时间:2023-09-11 21:53:28

我已经在网上搜索了多个小时,并且想到了要与其他人分享的解决方案:

I have searched the web for many hours and I came to this solution which I want to share for other people:

在数据库字段中使用BLOB代替text/varchar.这样,您可以像以前一样继续使用数据库表,并且表情符号可以正确显示.托管人更新MySQL版本后,我将继续使用UTF8MB4作为编码.

Use BLOB instead of text/varchar in the database fields. Like this, you can continue to use the database tables as you did before and the Emojis are shown properly. As soon as the hoster updates the MySQL version, I will continue with using UTF8MB4 as encoding.