MySQL连接器连接被hos强制关闭

2024-10-01 02:35:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在通过连接到2个数据库mysql.connect在

oldCnx = mysql.connector.connect(user='root', password='root', host='127.0.0.1', database='testdb', connect_timeout=10000)

以相同的方式连接到远程数据库集(仅使用其他凭据)。20(或60)分钟后,我得到错误:mysql.connector.errors.OperationalError: 2055: Lost connection to MySQL server at '127.0.0.1:3306', system error: 10054. An existing connection was forcibly closed by the remote host。在

怎么办?当连接被强制关闭时,我需要以某种方式扩展超时还是重新连接?如果是,我该怎么做?在


Tags: 数据库hostconnector远程connect方式mysqltimeout