MySQL Node js 与不同服务器的连接

MySQL connection on Node js with different servers

我是节点 js 的新手。为了安全起见,我在不同的服务器上分离了我的节点 js 和 mysql,我正在尝试建立这样的连接:

connMySql = mysql.createConnection({
    host: "IP_PUBLIC_SERVER",
    user: "user",
    password: "secret",
    database: "myDB",
    port: 3307
});

Return Error: connect ECONNREFUSED PUBLIC_IP:3307

我的问题是:是否可以在主机 属性 上使用 IP 建立远程连接?

提前致谢

我解决了打开 SSH 连接的问题,然后使用 localhost 作为主机连接 mysql。