Welcome aboard! We are happy you are here and wish you good net-raft!
// at first you install "npm install mysql"
//put this code into app.js
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "username",
password: "password",
database: "MyDb"
});
con.connect(function(err) {
if (err) throw err;
con.query("SELECT * FROM my_customers", function (err, result) {
if (err) throw err;
console.log(result); // or use console.log(result[1].name]); for concrete record
});
});
// type "node app.js" in command prompt
The most helpful NODEJS solutions
get user ipNODEJS Click to see more ... 7.5K 1.7K