我在具有静态IP地址的远程PC上安装了mysql。我想在另一个系统上访问该mysql服务器。我使用mysql工作台在另一台PC中创建了连接。在Workbench中,它工作正常,但是当我尝试使用Node.js进行连接时,这给了我错误。
nodejs中的代码:
var sql = require('mysql')
var connection = sql.createConnection({
//properties
host: 'static Ip of my remote Pc',
user: 'username',
password: 'password',
database: 'myDB',
connectionLimit : 100,
waitForConnections : true,
queueLimit :0,
debug : true,
wait_timeout : 28800,
connect_timeout :10,
});
function handleDisconnect() {
connection = sql.createConnection(connection)};
connection.connect(function (error) {
//callback function
if (error) {
if(error.code === 'PROTOCOL_CONNECTION_LOST') {
handleDisconnect();}
else
console.log('error', error);
setTimeout(handleDisconnect, 2000);
} else {
console.log('connected');
}
});
错误:
错误:是的, 消息:“错误iadan查询:2”, 状态:403, 数据: {错误:致命错误后无法排队查询。 在Protocol._validateEnqueue(/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_modules/mysql/lib/protocol/Protoco l.js:212:16) 在Protocol._enqueue(/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_modules/mysql/lib/protocol/Protocol.js:138:13) 在Connection.query(/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_modules/mysql/lib/Connection.js:201:25) 在userController.list(/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/controller/userController.js:9:13) 在Layer.handle [作为handle_request](/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_modules/express/lib/router/layer.js:95:5) 在下一个(/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_modules/express/lib/router/route.js:137:13) 在Route.dispatch(/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_modules/express/lib/router/route.js:112:3) 在Layer.handle [作为handle_request](/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_modules/express/lib/router/layer.js:95:5) 在/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_modules/express/lib/router/index.js:281:22 在param(/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_modules/express/lib/router/index.js:354:14)代码:“ PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR”,致命:false}}]