Connect to MySQL Server from Node.js But MySQL Server in remote location, How can i connect?
I tried below example :
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){
});
But I am getting Error :
Error Connection to DBError: getaddrinfo ENOTFOUND https://exmaple.com
Thanks in advance !
Did you try to estimate connection without set protocol type in hostname field:
var connection = mysql.createConnection({
host:"somelocation.com",
user:"root",
password:"roor"
});
In docs I see only this case for hostmane field: https://www.npmjs.com/package/mysql
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.