How to connect and find status of Mysql database
These are the steps we need to follow to connect Mysql database.
1. First install database dirver .
C:\Users\Your Name>npm install mysql
Now save those code in a js file .
a. create a varibale
a. create connection varibale .
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "tiger123"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
});
Test the the connection if scuccessful show connected else throw error .
$ node testconn.js
How to connect and find status of Mysql database
Reviewed by Mukesh Jha
on
5:36 AM
Rating:
No comments:
Add your comment