Connecting to MySQL Database in Node.js

Connecting Node.js to your MySQL database is extremely important to know for any system you will build where data storage is necessary. You can setup a local MySQL database on your system using MAMP and MySQL Workbench.

var mysql = require("mysql");

var connection = mysql.createConnection({
  host: "localhost",
  port: 3306,
  user: "root",
  password: "root", 
  database: "database_name"