const mysql=require('mysql');
//创建连接对象
const connection=mysql.createConnection({
host:'localhost',
user:'root',
password:'123123',
port:'3306',
database:'admin_demo'
})
//开始连接
connection.connect();
//执行mysql语句
const sql = 'select * from `user`'
connection.query(sql,(err,result)=>{
if(err){
console.log(err)
return;
}
console.log('result',result);
})
//关闭连接
connection.end();
网友评论