MEAN Stack with MySQL
MEAN stack is collection of JavaScript framework MongoDB, ExpressJS, Angular and NodeJs. Using MEAN, you can develop fast and robust web application.
But in this tutorial we will create an web application using MEAN (MySQL, ExpressJs, Angular, NodeJS). We are using M for MySQL instead of MongoDB. In this tutorial include features introduction, Angular with NodeJs, User Registration, User Login using JWT Token, CRUD Operations, Pagination using Server Side, Change Password etc.
All features available on this link MEAN (MySQL, ExpressJs, Angular, NodeJS). Next features will be available soon.
MySQL the most popular Open Source SQL database management system is developed, distributed and supported by Oracle Corporation. MySQL is the most popular language for adding, accessing and managing content in a database. In this MEAN adding and accesing data.
ExpressJS is a NodeJS web application framework that provides a robust set of features for web and mobile applications. In MEAN it is use for creating NodeJS app with set of features.
Angular is framework for creating single page application. Angular for building mobile and desktop applictions. In MEAN it use for client side.
NodeJS is a plateform thats run JavaScript on server side. In MEAN NodeJs use for creating API.
In this lesson we will learn setup mysql, nodejs, create nodejs app using express framework and connect mysql with nodejs.
Setup MySQL
Before use mysql in Node.js must be ensured MySQL Database should be installed in your machine. If MySQL is not installed in your machine then you can install from Installing MySQL documentation.
After setup MySQL then create database meanapp and create two tables
Setup NodeJs
NodeJS should be installed in your system. If not installed then you can watch this video Node.js Installation .
Create NodeJS App using ExpressJS
Intallation express-generator tool
We will install express-generator
tools globaly. If you have already installed express-generator
tool then no need to install.
Create a Application
Create a application using express-generator
tool
Install Dependencies
Install mysql node modules in node.js
Install mysql node modules in your application.
Create a Custom Module for Database Connection
Create a db.js file in the root folder for database connection and use this connection in your entire project. Connect your database using your MySQL database credential host, database user, database password and database name.
db.js
Check Database Connection
Now var db = require("../db");
file in routes/users.js
What is nodemon?
nodemon is a tool that helps run node.js based applications by automatically restarting the node application when file changes in the directory are detected.
Run NodeJs Application
You can run nodejs application using below commands.
orAfter run nodejs application using nodemon then you can see message some thing like below
Access nodejs application using url http://localhost:3000/
Conclusion
In this lesson we have learn what is MEAN and setup mysql, nodejs, create an app using expressjs and connect mysql with nodejs. Next lesson we will learn how to connect nodejs with angular 8.
This lesson also available on YouTube
More Posts - MEAN Stack
- MEAN Stack with MySQL
- Integrate Angular 8/9 with Node.js in MEAN Stack
- Routing, Lazy Loading Modules and Multiple Layouts in Angular 8/9
- User Registration in Angular 8/9 in MEAN Stack
- JWT Token Based Authentication using Passport in Node.js
- Angular 8/9 JWT Authentication with Example in MEAN Stack
- MEAN Stack Tutorial with CRUD Operations
- Server Side Pagination in MEAN Stack (MySQL, ExpressJS, Angular, NodeJS)
- Angular 9 Drag and Drop File Upload with Progress Bar using Node js API