iam
iam

Reputation: 1013

Emoji are not inserting in database node js mysql

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?

Upvotes: 25

Views: 15027

Answers (1)

Manish Prajapati
Manish Prajapati

Reputation: 1641

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/

Upvotes: 92

Related Questions