'Set encoding character set to utf8mb4 in Node.js or MySQL client?

When we want to store a string with emojis to our MySQL database, we get this error:

Conversion from collation utf8_general_ci into utf8mb4_unicode_520_ci impossible for parameter

Can someone explain to me why Node is sending it as utf8 to MySQL and how I can declare that we have an utf8mb4 collation? I tried several different encodings on the database side, but I think it is a Node.js or driver configuration that is missing.

The backend is based on Express.js, running on a Debian system within an lts-alpine docker container and the request is sent by a React Native app.

Thx, Florian



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source