sequelize: The utf8mb4 is not working
Bug Description
The utf8mb4 is not working. I can not insert emojis. It is working with localhost. But the remote connection has a bug.
Reproducible Example
Set the remote server as follows. https://i.imgur.com/Ktx8flD.png
Then execute the following code.
const sequelize = new Sequelize( config.DB_DATABASE, config.DB_USERNAME, config.DB_PASSWORD, {
host: config.DB_HOST,
dialect: 'mysql',
logging: false,
keepDefaultTimezone: true,
timezone: dayjs().format('Z'),
define: {
timestamps: false,
charset: 'utf8mb4',
}
});
sequelize.query(
"INSERT INTO emails (`subject`) VALUES ($subject);", {
bind: {
from: 'subject testπ'
},
type: QueryTypes.INSERT
});
What do you expect to happen?
I want to insert emoji in the MySQL database.
What is actually happening?
The emoji is stored as ???.
Environment
- Sequelize version: 6.35.1
- Node.js version: 16.14.2
- Database & Version: 10.3.39-MariaDB-cll-lve
- Connector library & Version: MYSQL2 3.6.5
Indicate your interest in the resolution of this issue by adding the π reaction. Comments such as β+1β will be removed.
About this issue
- Original URL
- State: open
- Created 7 months ago
- Comments: 23 (11 by maintainers)
Ok, have you built a sequelize model for the database or are you just using the
query
method to interact with the database from sequelize?Can you enable logging and set
logQueryParameters
to true in the sequelize instance and share the output, see example below.