1、安装插件
npm install mysql
2、调用代码
var mysql = require('mysql') var connection = mysql.createConnection({ host : 'localhost', user : 'root', password : 'root', database : 'sm1_syxcmzb_cn' }) connection.connect(); connection.query('select * from `tp_admin_user`',function (error, results, fields) { if (error) throw error; console.log('The solution is :', results) }) connection.end();