node连接mysql
时间:2021-07-01 10:21:17
帮助过:3人阅读
mysql=require("mysql"
);
var pool =
mysql.createPool({
host: ‘localhost‘
,
user: ‘root‘
,
password: ‘123456‘
,
database: ‘test1‘
,
port: 3306
});
var query =
function(sql,callback){
pool.getConnection(function(err,connection){
if(err){
callback(err,null,
null);
}else{
connection.query(sql, function (error, results, fields) {
//执行查询语句
connection.release();
//
callback(err,results,fields);
});
}
});
// conn.end();
};
module.exports = query;
node连接mysql
标签:span 语句 creat error word mod epo local password