AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL

Node.js MySQL Create Database


<< Previous Page
Nodejs tutorial
Next Page >>
Nodejs tutorial

Node.js Tutorial » Node.js create database

How do I create a node database?

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

Create Database Query: CREATE DATABASE db_name;
Use Database Query: USE db_name

 

Creating a Database

Use "CREATE DATABASE" statement to create a database in MySQL:

Example: create a database named "db_name":

var mysql = require('mysql');
var conn = mysql.createConnection({
host: 'localhost',
user: 'user_name',
password: 'pass',
database: 'db_name'
});
conn.connect(function(err) {
if (err) {
return console.error('error: ' + err.message);
}

console.log('Connected to the MySQL server.');
});

 

Related subjects:
node.js http module node.js Send Email upload files

 

Tags: node js create database: mysql, schema, postgres, mongodb database, sqlite 3 database, sequelize.
How do I create a node database?
Does node js have a database?
How do I create a database and table in node js?
How do I create a database connection in Node js?
node js mysql web application, create a node.js file that demonstrate create database and table in mysql, tutorial, mongodb, mongodb tutorial, connect to mongodb using mongoose

 

Save the code example

Save the code above in a file called "demo_test_create_db.js" and run the file:

Example: Run "demo_test_create_db.js"
E:\Users\Your_Name>node demo_test_create_db.js

 

Nodejs connect Database

Which will give you this result

Example: Include fs module, move the file to the current folder:
Connected!
Database created

 



node js create database: mysql, schema, postgres, mongodb database, sqlite 3 database, sequelize.
How do I create a node database?
Does node js have a database?
How do I create a database and table in node js?
How do I create a database connection in Node js?
node js mysql web application, create a node.js file that demonstrate create database and table in mysql, tutorial, mongodb, mongodb tutorial, connect to mongodb using mongoose
MySQL Create Database - nodejs

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


0
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


CSS background color - opacity, gradient...
CSS flex - display: flex - CSS Flexbox L...
CSS border padding...
HTML text center horizontally and vertic...
HTML text input <input type="text"&g...
HTML link color...
How to Link CSS to HTML, external file n...
HTML link - hyperlink...
jQuery replace...
jQuery replaceClass...
jQuery click ()...
jQuery switchClass()...
jQuery draggable()...
jQuery HTML...
jQuery scroll smooth...
jQuery scroll()...
jQuery stop()...
jQuery animate()...
jQuery SlideToggle()...
jQuery slideDown()...