Tuesday, August 2, 2022

Nodejs get data from Mysql database

 var mysql = require('mysql');

var con = mysql.createConnection({

  host: "localhost",

  user: "root",

  password: "12345",

  port: "3000",

  database: "project",

});

con.connect(function(err) {

  if (err) throw err;

  console.log("Connected!");

});

con.query('SELECT * FROM users', function (err, rows, fields) {

    if (err) throw err;

  console.log('The solution is: ', rows[2].standard);

  });

  con.end();

No comments:

Post a Comment