How to Connect ExpressJS with MySQL professional
1 min readFeb 24, 2020

Today I’ll show you the way I kind of connect to a mysql database and typescript. First let’s create the project and install dependencies:
$ mkdir my-sql && cd my-sql && npm init -y && npm i express cors body-parser mysql && npm i -D @types/node @types/express @types/body-parser @types/cors @types/mysql typescript tslib nodemon && mkdir ./src && mkdir ./src/{controllers,config} && touch ./src/controllers/controller.ts ./src/controllers/base-controller.ts ./src/index.ts ./nodemon.json ./src/config/mysql.ts && ./node_modules/typescript/bin/tsc --init
Let’s first open
./src/config/mysql.ts
Now Open
./src/controllers/base-controller.ts
Last Open a son controller
./src/controllers/base-controller.ts

From here the sky is the limit. If you want to see the whole project or part of it you is always welcome.