Node.js MySQL
Node.js mysql module is used to execute mysql database query like select, delete, update, insert etc.
Install MySQL Module
You can install mysql module using below command.
D:\nodejs\website> npm install mysql
Node.js can use this module to manipulate the MySQL database.
You can mysql module in you application as below require function.
const mysql = require('mysql');
Example :
var mysql = require('mysql');
var conn = mysql.createConnection({
host: "localhost",
user: "root",
password: "*******"
});
conn.connect(function(err) {
if (err) throw err;
console.log("Mysql server has been connected!");
});
//Output : Mysql server has been connected!
Comments