Node.js MySQL Create Database Tutorial

CREATE DATABASE statement is used to create a database in MySQL.

Node.js MySQL Create Database Example

var mysql = require('mysql');  
var con = mysql.createConnection({  
host: "localhost",  
user: "root",  
password: "12345"  
con.connect(function(err) {  
if (err) throw err;  
con.query("CREATE DATABASE javameant", function (err, result) {  
if (err) throw err;  
console.log("Database created");  

Now open command terminal and run the following command:

Node database.js  

© copyright 2017-2022 Completedone pvt ltd.