If you don't install MySQL then you can install MySQL by npm install mysql.

BY Best Interview Question ON 25 Jun 2020

Example

Create Connection

You can write connection code in a single file and call in all pages where you need to interact with database.

var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "your database username",
password: "database password"
});

con.connect(function(err) {
if (err) throw err;
console.log("Database Connected!");
});