Create MySQL Database with nodejs

The tutorial provides the node.js integration with MySQL Database operations. The tutorial provides the steps to create the MySQL Database using node.js application

Node.js MySQL Create Database

MySQL uses CREATE DATABASE statement . Let’s see the below node.js program on creating the database in MySQL Database. Save the below program as nodejs-mysql-create-db.js

var mysql = require('mysql');  
var con = mysql.createConnection({  
  host: "localhost",  
  user: "root",  
  password: ""  
con.connect(function(err) {
  if (err) throw err;
  console.log("MySQL Database Server is Connected successfully!");
  con.query("CREATE DATABASE oracleappshelpDB", function (err, result) {
    if (err) throw err;
    console.log("Database oracleappshelpDB is created successfully");
C:\Users\user\Desktop>node node.js-mysql-create-db.js
MySQL Database Server is connected successfully!
Database oracleappshelpDB is created successfully