0

Hi everyone I'm facing an issue with using NodeJS MySQL event and PHPMyAdmin and I keep getting this error TypeError [ERR_UNKNOWN_ENCODING]: Unknown encoding: utf8mb3 and its really frustrating I tried many things but so far no result.

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);
rawand feryad
  • 33
  • 1
  • 3
  • 11

1 Answers1

0

Finally, I sorted it out. the issue was in my MySQL code.

edit your SQL table code and change utf8mb3 to utf8mb4 for each table like the below example

ENGINE=InnoDB DEFAULT CHARSET=utf8mb3

to

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
rawand feryad
  • 33
  • 1
  • 3
  • 11