The following connection works using mysql node
// create mysql connection
const con = mysql.createConnection({
host: 'ip-208-109-35-193.ip.secureserver.net',
user: 'myusr',
password: 'mypass',
database : 'admin_ad',
port: '3306'
});
con.connect(function(err) {
if (err) {
console.log('Failed to connect MySQL.');
console.error(err);
return;
}
});
However when I try another host such as:
const con = mysql.createConnection({
host: '64.64.64.64',
user: 'myusr',
password: 'mypass',
database : 'admin_ad',
port: '3306'
});
The connection does NOT work. I tried these exact same credentials in a Sequel application locally (Sequel Ace) on mac and it works I get a connection. Does node mysql add somethign to the host or is there some type of protection set that needs to be undone? I have no idea why the same exact credentials that work on an application don't work on node mysql.
Digging into this I found that a server ip doesn't just "work". In example my hosting company has my server on a host named: "w4tr-gg7p.accessdomain.com" where the ip is 64.64.64.64. On a client such as Sequel Ace the ip works just fine. However on node mysql this does not work:
const con = mysql.createConnection({
host: '64.64.64.64',
user: 'myusr',
password: 'mypass',
database : 'admin_ad',
port: '3306'
});
Change the host to "w4tr-gg7p.accessdomain.com"
This is very confusing since in the node mysql documentation it always references the ip. I hope this helps someone that encounters this issue.