2013: Lost connection to MySQL server during query(查询期间与 MySQL 服务器的连接丢失)
MySQL含义
查询运行期间,客户端与 MySQL 服务器之间的连接断开。在服务器响应或返回结果之前连接就已中断。
原因
长时间运行的查询超过 net_read_timeout/net_write_timeout;服务器因内存不足(OOM)终止查询/连接;网络中断;超出 max_allowed_packet;服务器崩溃或重启;结果集非常大。
解决方法
检查网络稳定性和服务器错误日志;确认是否发生了 OOM 或崩溃。增大超时:SET GLOBAL net_read_timeout = 120; 将大查询拆分为多个批次。增大 max_allowed_packet。在应用中添加连接重试逻辑。优化长查询。
同一数据库的其他条目
- 1305PROCEDURE does not exist(PROCEDURE 不存在)
- 1227Access denied; you need (at least one of) the PRIVILEGE(访问被拒绝;需要(至少一项)PRIVILEGE 权限)
- 3730Cannot drop table referenced by a foreign key constraint(无法删除被外键约束引用的表)
- 1153Got a packet bigger than 'max_allowed_packet' bytes(收到的数据包大于 'max_allowed_packet' 字节)
- 1969MariaDB: Query execution was interrupted (max_statement_time exceeded)(MariaDB:查询执行被中断(超出 max_statement_time))
- 1927MariaDB: ER_CONNECTION_KILLED: Connection was killed(连接已被终止)
- 1290ER_OPTION_PREVENTS_STATEMENT: running with the --read-only option(以 --read-only 选项运行)