标签:
1、新版node自带npm 2、下载npm不需要node命令 3、懒得配环境变量、直接把生成的npm复制到报错目录,再把mysql模块复制回来
var mysql = require(‘mysql‘); var conn = mysql.createConnection({ host: ‘localhost‘, user: ‘root‘, password: ‘root‘, database:‘nodejs‘, port: 3306 }); conn.connect(); conn.query(‘SELECT * from fleam‘, function(err, re) { if (err) {throw err;} else{ console.log(re); } }); conn.end();
标签:
原文地址:http://www.cnblogs.com/hellowzd/p/4246940.html