node数据库安装和连接

https://www.bilibili.com/video/BV1a34y167AZ?p=59数据库安装步骤
npm install mysql --save
const mysqls = require('mysql')
const conn = mysqls.createConnection({
    connectionLimit: 10,
    host: 'localhost',
    user: 'root',
    password: 'zjxzhj123',
    port: '3306',
    database: 'mydb'
})
conn.connect()
let sql = 'SELECT * FROM mydb.users'
conn.query(sql,(err,result)=>{
    if (err) console.log(err);
    console.log(result);
})
conn.end()
 

 

posted @ 2022-02-10 13:31  zjxgdq  阅读(47)  评论(0编辑  收藏  举报