更新:This解决了问题!结果我忘了解除MySQL本地主机地址的绑定。
我正在尝试连接到运行在同一网络但与其他设备不同的IP地址的MySQL服务器。来自localhost的连接有效。
extern"C"
void *malloc(size_t){
return (void*)(0);
}
extern"C"
void free(void*){};
// C++ mini-definition of new & delete and aeabi_atexit:
void* operator new(size_t size, const std::nothrow_t& nothrow_value)throw(){
return malloc(size);
}
void* operator new(size_t size) {
return malloc(size);
}
void operator delete(void* p) throw(){
free(p);
}
extern"C"
int __aeabi_atexit(void*,void(*)(void*),void*){
return 0;
}
错误:
var connection = mysql.createConnection({
host : '172.16.3.170',
port : 3306,
user : 'root',
password : '',
database : 'owen_pm'
});
输出“ps ax | grep mysqld”
{ Error: connect ECONNREFUSED 172.16.3.170:3306
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1087:14)
--------------------
at Protocol._enqueue (/home/pi/pmsensor/node_modules/mysql/lib/protocol/Protocol.js:141:48)
at Protocol.handshake (/home/pi/pmsensor/node_modules/mysql/lib/protocol/Protocol.js:52:41)
at Connection.connect (/home/pi/pmsensor/node_modules/mysql/lib/Connection.js:130:18)
at query (/home/pi/pmsensor/test.js:50:14)
at Object.<anonymous> (/home/pi/pmsensor/test.js:86:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '172.16.3.170',
port: 3306,
fatal: true }
提前致谢!
更新:This解决了问题!结果我忘了解除MySQL本地主机地址的绑定。