大家好,我遇到了一个问题,使用NodeJS MySQL事件和PHPMyAdmin,我一直得到这个错误TypeError [ERR_UNKNOWN_ENCODING]:未知编码:utf8mb3和它真的很令人沮丧,我尝试了很多东西,但到目前为止没有结果。
const mysql = require('mysql');
const MySQLEvents = require('@rodrigogs/mysql-events');
const program = async () => {
const connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
});
const instance = new MySQLEvents(connection, {
startAtEnd: true,
excludedSchemas: {
mysql: true,
},
});
await instance.start();
instance.addTrigger({
name: 'TEST',
expression: 'test.*',
statement: MySQLEvents.STATEMENTS.ALL,
onEvent: (event) => { // You will receive the events here
console.log(event);
},
});
instance.on(MySQLEvents.EVENTS.CONNECTION_ERROR, console.error);
instance.on(MySQLEvents.EVENTS.ZONGJI_ERROR, console.error);
};
program()
.then(() => console.log('Waiting for database events...'))
.catch(console.error);
1条答案
按热度按时间tzcvj98z1#
最后,我解决了这个问题。问题出在我的MySQL代码中。
编辑您的SQL表代码,并将每个表的utf8mb3更改为utf8mb4,如下例所示
至