Reference

https://www.youtube.com/watch?v=bqpgbTq8bbw

How to connect Express to MyuSQL

 

 

npm init --y

npm install --save mysql



 

// app.js

const mysql = require('mysql');

const connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'username',
  password : 'password',
  database : 'databasename'
});

connection.connect((err) => {
    if(err) throw err;
    console.log('Connected to MySQL Server!');
});

 

node app.js


>> Connected to MySQL Server!