表情符号未插入数据库节点js mysql中 [英] Emoji are not inserting in database node js mysql

查看:89
本文介绍了表情符号未插入数据库节点js mysql中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我在这里讨论一件事.我正在建立一个Web服务,其目标是将表情符号数据插入数据库字段.我正在使用Node JS + Mysql. 我将字符集设置为 UTF-8 utf8mb4 ,但这不能解决我的问题. 一些表情符号正在插入完美的{:)}.但其中一些会转换为正方形或已删除. 请在我做错事的地方帮我吗?

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?

推荐答案

请在您的mysql连接池中添加 charset:'utf8mb4'.

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

例如

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

原始帖子: https://www.koffeewithkode.com/emoji-are-not-inserting-in-database-node-js-mysql/

这篇关于表情符号未插入数据库节点js mysql中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆