1

I use Node.js, MYSQL and want to write emoji.

My MYSQL's character set and collation all sets on 'utf8mb4' and when I insert emoji with SQL, I can see emoji well. (Probably It means There's no problem in MYSQL settings)

But When I send emoji with Postman or application which using node.js, emoji is converted into '?' (question mark).

Here is my dbconfig.js.

const mysql = require('promise-mysql')
require('dotenv').config();

const dbConfig = {
    host: process.env.DB_HOST,
    port: process.env.DB_PORT,
    user: process.env.DB_USER,
    password: process.env.DB_PASSWORD,
    database: process.env.DB_DATABASE, // insert db name
    dateStrings: process.env.DB_DATESTRINGS,
    charset: 'utf8mb4'
}

module.exports = mysql.createPool(dbConfig)

What more should I do?

MinJoon
  • 11
  • 1
  • 1
    https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/ and https://kunststube.net/encoding/ – spencer7593 May 28 '20 at 13:28
  • From within the code, display `SHOW VARIABLES LIKE 'char%';` (It can be run like a `SELECT`, retrieving rows and columns.) – Rick James May 31 '20 at 18:02
  • The problem is probably in another place. Check "question mark" in https://stackoverflow.com/questions/38363566/trouble-with-utf-8-characters-what-i-see-is-not-what-i-stored Also do the debugging suggested about `SELECT HEX(col)`; the inserts may have been wrong, but your debugging so far had "two wrongs making a right". – Rick James May 31 '20 at 18:05
  • Hi guys, Thanks for all of your comments. I fixed it through Procedure Settings. My error was caused cuz I used procedure and didn't set utf8mb4 on procedure. Thanks – MinJoon Jun 18 '20 at 02:29

0 Answers0