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.


Upload Image, display, edit and delete i...
Login Form with Image background...
How to Create an Image with Transparent ...
Portfolio Gallery Website with filtering...
Simple pagination script PHP MySQLi...
Center Image in div...
Image Hover Overlay Fade...
Sticky image / element / div on scroll...
Responsive images...
Create rounded image in HTML CSS...
Add border around image...
Position Text Over an Image HTML CSS res...
Create a Slideshow Images Gallery...
Create a Sticky Sidebar...
Search bar using CSS HTML...
Shrink Navigation Menu on Scroll...
How to Create Accordion HTML Templates...
Dropdown menu in the navigation bar...
Responsive Top Navigation Bar with mobil...
Split horizontal navigation bar...