how do I get rid of these errors when trying to connect to mysql database?

34 views Asked by At

I'am building a website for the first time and I'm using nodejs along with expressjs and mysql to deal with my database. I started out using port 3000 locally and then i started using phpmyadmin because my database contains a lot of special caracters which meant that i wasn't able to properly import my csv file into my database. Because mysql in phpmyadmin runs automatically on port 3306 I created a connection to port 3306 using the same user and password as my connection to port 3000 (I'm not sure if this is relevant). Now that I've done all of this, I keep on getting errors concerning my connection to the database : these are the errors Ive gotten so far, I've managed to get rid of a few of them using some Youtube tutorials but I'd like to know what they're real reason is and if it has something to do with me changing the port that i was listening to or if it has no correlation to the errors i'm getting (i didn't have any issues connecting to my database when i was on port 3000) :

"Error: Packets out of order. Got: 80 Expected: 0 code: 'PROTOCOL_PACKETS_OUT_OF_ORDER', fatal: true"

"code: 'PROTOCOL_SEQUENCE_TIMEOUT', fatal: true, timeout: 10000"

"Connection lost: The server closed the connection. fatal: true, code: 'PROTOCOL_CONNECTION_LOST' "

ALso, this is the database configuration I'm using :

const mysql = require('mysql2');
require('dotenv').config();
const pool = mysql.createPool({
  connectionLimit: 5000,
  connectTimeout: 60 * 60 * 1000,
  host: process.env.DATABASE_HOST,
  user: process.env.DATABASE_USER,
  password: process.env.DATABASE_PASSWORD,
  database: process.env.DATABASE,
  charset: 'utf8mb4',
  idleTimeoutMillis: 60000
});

I've tried multiple solutions i've found here and on other websites but none seem to work.

0

There are 0 answers