
1、先安装mysql
$ npm install mysql
2、直接上代码
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '123456',
database : 'dataname'
});
connection.connect();
connection.query('查表的SQL语句', function (error, results, fields) {
if (error) throw error;
console.log('The solution is: ', results[0].solution);
});
标签: mysql
上面是“用nodejs搭建一个MySQL版的接口”的全面内容,想了解更多关于 nodejs 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_88.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

手游《永劫无间》科目三动作怎么获取
SEO新手在网站优化中应该注意哪些点?
纯CSS饼图效果
推荐一款完全免费可商用的摄影图库网站——Picography