首先使用npm install mysql
var mysql = require('mysql'); var conn = mysql.createConnection({ host: 'localhost', user: 'root', password: '123456', database: 'mysql', port: 3306 }); conn.connect(); conn.query( 'select * from user', function (err, res, fields) { if (err) throw err; for ( var i = 0; i < res.length; i++ ) { var obj = res[i]; console.log(obj); } } ); conn.end();
了解 工作生活心情记忆 的更多信息
Subscribe to get the latest posts sent to your email.