i try to create mysql and nodejs express image
when i run mysql and backend container and open my frontend
english text can display but if data is thai text when i use mysql2 to fetch thai text
the text will be alien language
here is example data in sql
| แผนลับดับศัตรู |
| แผนลับดับศัตรู |
| แผนลับดับศัตรู |
| แผนลับดับศัตรู |
| KonoSuba ss1
| KonoSuba ss1
as you see i can display correct thai text in mysql image i try to make api to get image and title of anime
await pool.query('SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci'); let get_image_and_title =
SELECT DISTINCT title, anime_image FROM animeconst image_and_title = await pool.execute(get_image_and_title) console.log("Retrieved titles:", image_and_title);//this is array of obj contain blob image and text in example sql i give to you "KonoSuba ss1" can display normally but "แผนลับดับศัตรู" is à¹à¸œà¸™à¸¥à¸±à¸šà¸”ับศัตรู
MySQL connection configuration in nodejs is
`const mysql = require(‘mysql2’);
const pool = mysql.createPool({
host: ”,
user: ”,
password: ”,
database: ”,
charset: ‘utf8mb4’,
collation: ‘utf8mb4_unicode_ci’,
encoding: ‘utf8mb4’,
});
console.log(‘mysql2 pool ready’)
module.exports = pool.promise(); // Export the promise-based pool`
Dockerfile
`FROM node:20.10.0
ENV NODE_ENV=production
WORKDIR /app
COPY [“package.json”, “package-lock.json*”, “./”]
RUN npm install –production
COPY . .
CMD [“npm”, “start”]
`
i try to set UTF-8 in many places but i still got alien language
What i do wrong?
or What i should check to ensure both mysql and backend is endcoding correctly