标签:node mysql
var mysql = require(‘mysql‘);
var client = mysql.createConnection({
host: ‘112.124.54.74‘,
port: 3306,
user: ‘yin‘,
password: ‘691331‘,
database: ‘hu‘
});
client.connect(function(error, results) {
if(error) {
console.log(‘Connection Error: ‘ + error.message);
return;
}
console.log(‘Connected to MySQL‘);
});
client.query(‘SELECT * from hero‘, function(err, rows, fields) {
if (err) throw err;
console.log(‘The solution is: ‘, rows[0].name);
});
client.end();
标签:node mysql
原文地址:http://cocos2014.blog.51cto.com/2193129/1441030