
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,我们会在看到邮件的第一时间内为您处理!

在帝国CMS后台增加手动添加会员功能
紫东太初APP最新版
咕噜口语SpeakGuru
hbuilder编辑器上安装git插件(克隆项目/同步代码/提交代码等)