var mysql = require('mysql'); var con = mysql.createConnection({ host: "localhost", user: "root", password: "root", database: "db_name" }); con.connect(function(err) { if (err) throw err; con.query("SELECT roll_number, first_name, last_name, divison FROM students", function (err, result, fields) { if (err) throw err; console.log(result); }); });