node js mysql连接

时间:2017-12-08 17:59:48

标签: mysql sql node.js

我有一个nodejs应用程序,并希望将应用程序连接到mysql远程主机。这是我的查询

mysql -u user -p password -h http://xxx.xxx.com

但是收到错误ERROR 2005(HY000):未知的MySQL服务器主机' http://xxx.xxx.com' (0)。

and here is nodejs code both are not working

var connection = mysql.createConnection({
 host     : 'http://xxx.xxx.com',
 hostname : 'xxx.xxx.com',
  user     : 'user',
  password : 'password'
 });

   connection.connect(function(err){
   });


  connection.query('SELECT * from test', function(err, rows, fields) {
   if (!err)
  console.log('The solution is: ', rows);
  else
  console.log('Error while performing Query.');
  });

 connection.end();

提前致谢

0 个答案:

没有答案