Step 1: Open xampp, start mysql, open shell command Part 2: Create a file with the suffix SQL with vscode Part 4: Enter in the VScode interface

Set names utf8 for client to connect to server set names UTf8 for client to connect to server Creat table creat table name (); Insert into table values (); (a); (a);Copy the code

Step 5: Return to Step 1 and open the shell window. Enter the absolute path to the mysql -uroot< SQL file and press Enter

Note: There is a space between mysql and -uroot, and no space between -u and rootCopy the code

Step 6: Show Databases; Step 1: Show databases; Step 2: Show databases; Step 2: Show databases; step 2: Show databases; step 3: Show databases; Enter, use database name; Select * from table desc; Step 8: Create a THREE-tier MVC structure, model {database operation}, view {user and system interaction}, Controller {business logic operation}, so create routes file. App.js (server), pool.js(connection pool), and the View folder (not detailed here) Open the file on a terminal and type NPM install Express and NPM install mysql

                const mysql=require("mysql")
                const pool=mysql.creatpool(
                hostname:"",
                port:"",
                user:"",
                password:"",
                root:"",
                databases:"",
                connectionLimit:""
               );
               model.exports=pool
Copy the code

Step 11: Open app.js with vscode and type the following

const express=require("express"); Const router=require("routes ") const app=express(); app.listen(8080); App.use (express,urlencoded){extends:false} app.use(' prefixes ',router); app.use((err,req,res,next)=>{ console.log(err); Res.status (500).send({code:500, MSG :" server error "})Copy the code

Step 12: Open the JS file under routes with vscode

const express=require("express"); Const pool=require(" connection pool path "); const router=require("router"); Let obj=req. Body; let obj=req. Body; var sql=""; if(obj,user){ res.send({ code:400, msg:"" }) } pool.query(sql,[obj],funaction(err,result){ try{ console.log(result); Res.send ({code:"400", MSG :" data access success "})}catch{if(err){next(err); return; } } }) }) model.exports=router;Copy the code

Step 13: Enter the Node app at the terminal, start the server, copy httP://IP address: port number/prefix/route to the APIPOST software. If the return result is successful, otherwise check the code