原因:
使用.end()方法或出错导致数据库连接断开。
解决方法(两种方法):
1.每次关掉连接之后,用 createConnection()方法创建一个新连接。
2.将连接一直保持,不要使用.end()断开连接。(通过 mysql show global variables like ‘wait_timeout’ 查询不活跃状态下断开连接的等待时间)
原因:
使用.end()方法或出错导致数据库连接断开。
解决方法(两种方法):
1.每次关掉连接之后,用 createConnection()方法创建一个新连接。
2.将连接一直保持,不要使用.end()断开连接。(通过 mysql show global variables like ‘wait_timeout’ 查询不活跃状态下断开连接的等待时间)