”工欲善其事,必先利其器。“—孔子《论语.录灵公》
首页 > 编程 > 如何修复\“常规错误:2006 MySQL Server在插入数据时已经消失\”?

如何修复\“常规错误:2006 MySQL Server在插入数据时已经消失\”?

发布于2025-03-11
浏览:616

How to Fix \

How to Resolve "General error: 2006 MySQL server has gone away" While Inserting Records

Introduction:
Inserting data into a MySQL database can occasionally result in the error "General error: 2006 MySQL server has gone away."当与服务器的连接丢失时,通常是由于MySQL配置中的两个变量之一。

解决此错误的键是调整Wait_Timeout和Interactive_time_timeout variables。 These variables control the maximum time that MySQL will wait before terminating an inactive connection.

Adjusting Timeout Variables:

Connect to the database using your preferred method (e.g., PHP, SQL console).

Execute the following query: SET session wait_timeout = 28800
    此外,如果遇到错误“常规错误:2013丢失在查询期间与mySQL Server的连接丢失”,您也可能需要执行:SET SESSITIOD_TIMETIVE_TIMETIVE_TIMER = 28800
  1. execute execute the Updation the Uperatife decarify varriables: '%timeout%'
  2. 在php中的示例:
  3. = $ row; } $ stmt-> close(); 返回$ set; } } }
  4. 附加注意事项:
  5. wait_timeout的默认值为28800秒(8小时),这是过多的。建议将其设置为较低的值,例如300秒。
  6. 增加超时值应谨慎完成,因为如果连接未正确关闭,可能会导致性能问题。
最新教程 更多>

免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。

Copyright© 2022 湘ICP备2022001581号-3