0

I was trying to connect to my localhost:3306 using NodeJS, and below is the code for the same

const mysql = require('mysql');

const connection = mysql.createConnection({
    host: 'localhost',
    port: 3306,
    database: 'test',
    user: 'root',
    password: 'root'
});

connection.connect(function (err) {
    if(err) {
        console.log("error occured")
    }
    else {
        console.log("connection created")
    }
})

On running the js file, I am getting error occured and not able to print connection created. Any kind of help would be appreciated.

0 Answers0