从Node.js连接到MySQL服务器但是远程位置的MySQL服务器,我该如何连接?
我试过下面的例子:
var mysql = require("mysql");
var connection = mysql.createConnection({
host:"http://somelocation",
user:"root",
password:"roor"
});
connection.connect(function(err){
if (err) {
console.log("Error Connection to DB" + err);
return;
}
console.log("Connection established...");
});
connection.end(function(err){
});
但我收到错误:
Error Connection to DBError: getaddrinfo ENOTFOUND https://exmaple.com
提前致谢!
答案 0 :(得分:0)
您是否尝试在主机名字段中未设置协议类型的情况下估算连接:
var connection = mysql.createConnection({
host:"somelocation.com",
user:"root",
password:"roor"
});
在文档中,我只看到了这个案例的主题:https://www.npmjs.com/package/mysql