Node.js MySQL Create Database
Node.js MySQL Create Database
The CREATE DATABASE statement in MySQL is used to create a new database. In this tutorial, we’ll learn how to create a MySQL database using Node.js.
Data Science Tutorial:–Click Here
Example
Let’s create a database named “updategadh” using Node.js.
First, create a JavaScript file named updategadh.js inside a folder named DBexample and add the following code:
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "12345"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
con.query("CREATE DATABASE updategadh", function (err, result) {
if (err) throw err;
console.log("Database created");
});
});
Running the Script
Introduction to Applied AI:–Click Here
Open your terminal, navigate to the DBexample folder, and run the following command:
node updategadh.js
If the connection and query execute successfully, you’ll see the following messages in your terminal:
Connected!
Database created
This means your updategadh database has been successfully created.
Download New Real Time Projects :–Click here
Verification
To confirm that the database has been created, open your MySQL command prompt and use the following command:
SHOW DATABASES;
You’ll see updategadh listed among the available databases, indicating that your new database was created successfully.
Machine Learning Tutorial:–Click Here
Complete Advance AI topics:- CLICK HERE
Deep Learning Tutorial:– Click Here
Complete Python Course with Advance topics:-Click Here
SQL Tutorial :–Click Here
node js mysql create database example node js mysql create database w3schools avascript mysql database connection example node js mysql query return result connect mysql with node js express database connection in node js with mongodb node js mysql connection node js database connection mysql create database javascript, nodejs mysql database tutorial, sequelize mysql database with nodejs, nodejs + expressjs + mysql database connection, nodejs + mysql database connection tutorial, mysq; database connection with nodejs, how to connect mysql database in node.js, how to connect to mysql database from node.js, nodejs mysql crud, mysql database, relational database nodejs, mysql database connection in node js, nodejs mysql, databasing with mysql and nodejs, learn nodejs databases, nodejs mysql2



Post Comment