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();


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。