MySQL in Node 101: Setup and Access

Jack Yeh
TeamZeroLabs
Published in
8 min readFeb 16, 2020

--

Photo by Tobias Fischer on Unsplash

Level: Web Developer Beginner

If you are new to the web developer world, you may be wondering what comes after the HTML and JavaScript track on w3schools. The static website project has a couple of interactive buttons and animations, but how do we display dynamic data?

This article is for you! We will cover the following:

  • Setting up a local MySQL database on your laptop with Docker.
  • Installing a database package into your express app.
  • Setting up Database connection on startup.
  • Reading from the Database when a request happens.
  • Writing into the Database when a request happens.
  • Part 2: what if we are using TypeScript? Or another web framework?

Step 0: The Setup

  1. Pick a nice Editor. I use WebStorm with Prettier enabled.
  2. Install Docker on your local environment. You can find a direct download link for Mac here: https://download.docker.com/mac/stable/Docker.dmg
  3. Is Node available? Check with running node -v . If you do not have Node.JS yet, check out https://github.com/nvm-sh/nvm
  4. Is Git available? Check with running git in the command line. On Mac, typing git without it…

--

--

Jack Yeh
TeamZeroLabs

I monitor your full stack deployment in production, so you can sleep at night. Docker | Kubernetes | AWS | Prometheus | Grafana