Database connection working fine with localhost but not working with remote host.I got the ip from my cpanel that is shared ip. is there anything i am missing?
const db = mysql.createConnection({
host: '195.201.179.80',
user: '****',
password: '****',
database: 'enamme_m-tube'
});
db.connect(function (err) {
if (err) throw err
console.log('Connection Established To Mysql Database')
})
Note: My Node app is running on localhost.
Error :
Error: connect ECONNREFUSED 195.201.179.80:3306 at Object._errnoException (util.js:992:11) at _exceptionWithHostPort (util.js:1014:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
2
Answers
You should to connect to MYSQL under
root
and send query:Did your mysqld binding on public IP address? As default mysqld will bind to the UNIX socket. Try adding this in your /etc/my.cnf