I have updated my node version, and now I can't access to my DB with my app. I tried many things: -Change rout to 127.0.0.1. -add my port number 3306 -add socketPath: '/Applications/MAMP/tmp/mysql/mysql.sock' -kill node running And probably others, but I always have an error. Actually, I have this one while running this code. Error:
disconnected
error: connect ECONNREFUSED ::1:3306
My code who was working before:
const mysql = require('mysql');
const db = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "discord"
});
if (db.state === 'disconnected') {
db.connect(function (err) {
if (err) { return console.error('error: ' + err.message); }
console.log('Connected to the MySQL server.');
});
}
console.log(db.state);
module.exports = db