Connect to the database in the framework automatically generated by express
connect.js Code
const mysql = require("mysql");
const db = mysql.createConnection({
host: "localhost",
port: 3306,
user: "root",
database: "ningxia"
})
db.connect((error) => {
if (error) {
console.log(error)
console.log("")
} else {
console.log("")
}
})
module.exports = db
introduce the connect.js file into the Index.js of api, and the small blackboard indicates that the connection failed