Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过本地机器连接远程mysql:node expressjs_Mysql_Node.js_Express_Meanjs - Fatal编程技术网

通过本地机器连接远程mysql:node expressjs

通过本地机器连接远程mysql:node expressjs,mysql,node.js,express,meanjs,Mysql,Node.js,Express,Meanjs,我正在尝试连接到远程mysql(托管在digitalocean服务器上),并在本地机器中使用db for代码 当我启动节点服务器并请求数据时,我得到以下错误 {"ERRORMSG":"Something went wrong.{\"code\":\"ENOTFOUND\",\"errno\":\"ENOTFOUND\",\"syscall\":\"getaddrinfo\",\"hostname\":\"http://ip.of.remote.server/\",\"host\":\"http:

我正在尝试连接到远程mysql(托管在digitalocean服务器上),并在本地机器中使用db for代码

当我启动节点服务器并请求数据时,我得到以下错误

{"ERRORMSG":"Something went wrong.{\"code\":\"ENOTFOUND\",\"errno\":\"ENOTFOUND\",\"syscall\":\"getaddrinfo\",\"hostname\":\"http://ip.of.remote.server/\",\"host\":\"http://ip.of.remote.server/\",\"port\":3306,\"fatal\":true}"}
在第一次尝试之后,如果我再次刷新,我会得到不同的错误

{\"code\":\"PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR\",\"fatal\":false}
连接方式如下:

connection = mysql.createConnection({
    connectionLimit: 10000, //important
    host: 'http://ip.of.remote.server/',
    user: 'user',
    password: 'password',
    database: 'db',
    multipleStatements: true,
    connectionLimit : 100,
    waitForConnections : true,
    queueLimit :0,
    debug    :  true,
    wait_timeout : 28800,
    connect_timeout :10
});
电话是这样打的

app.get('/WSgetdata', function (req, res) {
    var q = "CALL sp_get_data();" 
    var obj = {};
    connection.connect();
    connection.query(q, function (err, rows) {

        if (err) {
            obj.ERRORMSG = JSON.stringify(err);
        }
        else if((rows[rows.length-1])[0].ERRORSTATUS == 0){
            //do something
        }
        res.end(JSON.stringify(obj))
    });
});
怎么了。当代码和数据库在同一台机器上时,它可以正常工作。 我还可以从所需的IP访问db

痕迹

替换

host: 'http://ip.of.remote.server/',


是否可以连接mysql cli客户端或任何其他工具?可能端口被阻止?错误2003(HY000):无法连接到“ip.of.remote.server”(10061)上的MySQL服务器
host: 'http://ip.of.remote.server/',
host: 'ip.of.remote.server',