1 of 10

Express - Structured Data: MySQL

Web Technology

Subin Sahayam, Assistant Professor,

Department of Computer Science and Engineering

Shiv Nadar University

2 of 10

MySQL

  • Download and Install MySQL GPL Edition

K3

3 of 10

MySQL

  • Download and Install MySQL GPL Edition
  • Check if MySQL is Running
    • Open Services -> Check MySQL80 (Should be running)
    • Set Path to Environment Variable
    • Open VSCode
    • Try Logging into Your SQL Login via Command Prompt
    • mysql --version : To check mysql installed or not
    • sudo systemctl status sql : To check the status
    • sudo systemctl enable mysql : To enable mysql

K3

4 of 10

MySQL

  • Create a Database and Use

K3

CREATE DATABASE student_db;

​

​

DROP DATABASE student_db;

  • Delete a Database and Use

5 of 10

MySQL

  • Create a Table as follows,

K3

USE student_db;

​

CREATE TABLE student_tab (

id INT AUTO_INCREMENT PRIMARY KEY,

name VARCHAR(100),

department VARCHAR(50),

marks INT

);

6 of 10

MySQL

  • Insert Values into Table as follows,

K3

INSERT INTO student_tab (name, department, mark)

VALUES

('Rourab', 'CSE', 85),

('Amit', 'CSE', 78),

('Rahul', 'ECE', 92);

7 of 10

MySQL

  • Connect express to mysql
  • Read from express using select query
  • Display the content as JSON file
  • Install the following,

             npm install mysql2

K3

8 of 10

MySQL

  • Connect express to mysql using environment variables
  • Install the following,

             npm install dotenv

  • Create .env file
  • Create express file

K3

9 of 10

References

​

​

​

​

​

  1. Evan Hahn, “Express in Action: Writing, Building, and Testing Node.js Applications" – 15 April 2016, First Edition.
  2. Brad Dayley, Brendan Dayley, Caleb Dayley, “Node.js, MongoDB and Angular Web Development: The definitive guide to using the MEAN stack to build web applications”, Pearson Education, Second Edition, 2017.
  3. Greg Lim, “Beginning MERN Stack: Build and Deploy a Full Stack MongoDB, Express, React, Node.js App,” 2021.

​

10 of 10

THANK YOU