Advertisement
Guest User

javascript mysql db connection

a guest
Feb 13th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var mysql = require('mysql');
  2.  
  3. var con = mysql.createConnection({
  4.   host: "localhost",
  5.   user: "root",
  6.   password: "",
  7.   database: "experiment"
  8. });
  9. /*
  10. con.connect(function(err) {
  11.   if (err) throw err;
  12.   console.log("Connected!");
  13. });
  14. */
  15. con.connect(function(err) {
  16.   if (err) throw err;
  17.   console.log("Connected!");
  18.   con.query("SELECT * FROM users", function (err, result) {
  19.     if (err) throw err;
  20.     console.log("Result: " + result);
  21.   });
  22. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement