Emoji are not inserting in database node js mysql

蹲街弑〆低调 提交于 2019-12-04 09:37:38

问题


Hello I am here to discus one thing. I am building up a web service that makes a goal for inserting emoji data into database field. I am working with Node JS + Mysql. I set charset to UTF-8 or utf8mb4 but this is not solving my problem. some emoji are inserting perfect { :) }. but some of are converted into square or removed. Please help me where I am doing wrong thing?


回答1:


please add charset : 'utf8mb4' in your mysql connection pool.

e.g.

var connection = mysql.createConnection({
    host : 'you_ip',
    user : 'user',
    password : 'password',
    database : 'db',
    charset : 'utf8mb4'
});

Original Post: https://www.koffeewithkode.com/emoji-are-not-inserting-in-database-node-js-mysql/



来源:https://stackoverflow.com/questions/36280148/emoji-are-not-inserting-in-database-node-js-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!