I recently reformatted my server and did the usual back up. However ever since I've gotten my server back online i'm facing an error on my database. I manually checked if the tables are working and they are; I can access them on phpmyadmin. I'm checking if the database is properly connected; I even tried reconnecting the database when it breaks down; however I'm still facing the same error. I've tried pool connections and it was no help. I've tried manually reconnecting to the database upon errors and it still produces the same error. Here is my code:
/* MYSQL CONNECTION */
var db;
function choke(){
/* CREATE THE CONNECTION */
let db = mysql.createConnection({
host: "127.0.0.1",
user: "admin",
password: "",
multipleStatements: true
});
db.connect(err=>{
if(err) {
console.log(err);
}
console.log("DB connected Successfully!!")
})
/* ERROR HANDLER */
db.on('error', function(err){
if(err.code == 'PROTOCOL_CONNECTION_LOST'){
/* RECURSE FUNCTION */
choke();
}else{
/* DATABASE ERROR. */
console.log(err)
}
});
}
choke();
The error I recieved was:
code: 'PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR',
fatal: false
The code was all working fine before the reformat so it has something to do with the settings of the database rather than a coding error.