phpmyadmin [ERR_UNKNOWN_ENCODING]错误代码:未知编码:UTF8MB3语言

omhiaaxx  于 2022-11-09  发布在  PHP
关注(0)|答案(1)|浏览(261)

大家好,我遇到了一个问题,使用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);
tzcvj98z

tzcvj98z1#

最后,我解决了这个问题。问题出在我的MySQL代码中。
编辑您的SQL表代码,并将每个表的utf8mb3更改为utf8mb4,如下例所示

ENGINE=InnoDB DEFAULT CHARSET=utf8mb3

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

相关问题