Connect to mySQL with node.js
var mysql = require('mysql'); var con = mysql.createConnection({ host: "localhost", port: "8889", user: "root", password: "root", database: "stoks" }); con.connect(function (err) { if (err) throw err; console.log('Connected to DB'); con.query("SELECT * FROM stok ORDER BY symbol", function (err, result) { if (err) throw err; console.log(result); }); }); con.end();