您的位置:首页 > 博客中心 > 数据库 >

node mysql

时间:2022-03-10 18:08


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


热门排行

今日推荐

热门手游