-1

I have configured the connection in Nodejs file as shown below. The problem happens when trying to connect to the remote database on a server

module.exports = {
    host: '234.32432.32432',//this is example IP not a real one.
    user: 'bob',
    password: '*****',
    database: '****',
    port: 3306,
    dialect: 'mysql',
}
nbk
  • 45,398
  • 8
  • 30
  • 47
  • 1
    what's the error you get? please note, usually mysql is configured to accept local connections only, that might be the problem – GrafiCode Jul 30 '22 at 10:28
  • this is the error: parent: Error: connect ECONNREFUSED 234.32432.32432:3306 [0] at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { [0] errno: -4078, [0] code: 'ECONNREFUSED', [0] syscall: 'connect', [0] address: '234.32432.32432', [0] port: 3306, [0] fatal: true [0] }, – symix world Jul 30 '22 at 10:30
  • if mysql is configured to accept local connections only, then how can i connect to remote database on specific server please? – symix world Jul 30 '22 at 10:31

1 Answers1

0

You need configure your mysql to allow remote connection.
Edit file /etc/mysql/mysql.conf.d/mysqld.cnf You will Find a line looks like this:

bind-address            = 127.0.0.1

Change it to this:

bind-address            = 0.0.0.0

After saving, restart your mysql.

Notice:

In certain versions of MySQL the bind-address directive may not be in the mysqld.cnf file by default.