我在c9环境下完成了我的项目,现在我正尝试在本地服务器上使用它。我的数据库运行在个人本地服务器上,看起来像8080上的mamp。我的网络服务器8888。问题是,当我尝试使用mysql.createPool函数时,我有一个超时,并出现以下错误:
{ Error: Handshake inactivity timeout
at Handshake.<anonymous> (/Users/me/http/MyWebSite/matcha/node_modules/mysql/lib/protocol/Protocol.js:160:17)
at emitNone (events.js:86:13)
at Handshake.emit (events.js:185:7)
at Handshake._onTimeout (/Users/me/http/MyWebSite/matcha/node_modules/mysql/lib/protocol/sequences/Sequence.js:127:8)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
--------------------
at Protocol._enqueue (/Users/me/http/MyWebSite/matcha/node_modules/mysql/lib/protocol/Protocol.js:141:48)
at Protocol.handshake (/Users/me/http/MyWebSite/matcha/node_modules/mysql/lib/protocol/Protocol.js:52:41)
at PoolConnection.connect (/Users/me/http/MyWebSite/matcha/node_modules/mysql/lib/Connection.js:130:18)
at Pool.getConnection (/Users/me/http/MyWebSite/matcha/node_modules/mysql/lib/Pool.js:48:16)
at /Users/me/http/MyWebSite/matcha/routes/users.js:96:14
at Layer.handle [as handle_request] (/Users/me/http/MyWebSite/matcha/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/me/http/MyWebSite/matcha/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/Users/me/http/MyWebSite/matcha/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/me/http/MyWebSite/matcha/node_modules/express/lib/router/layer.js:95:5)
at /Users/me/http/MyWebSite/matcha/node_modules/express/lib/router/index.js:277:22
code: 'PROTOCOL_SEQUENCE_TIMEOUT',
fatal: true,
timeout: 10000 }下面是我的createPool函数:
module.exports = mysql.createPool({
connectionLimit: 100,
host: 'localhost',
port: 8080,
user: 'me',
password: ''});我在不同的端口上分别使用和不使用密码进行了尝试。我发现了一些关于Node4.2版本的问题,但我使用的是7.4.0
发布于 2021-06-01 02:42:22
尝尝这个。
{
"host": "",
"database": "",
"user": "",
"password": "",
"port": 3306,
"connectionLimit": 100,
"queueLimit": 100,
"acquireTimeout": 1000000,
"connectTimeout": 30000,
"debug": false
},https://stackoverflow.com/questions/41958596
复制相似问题