`
duan1823a
  • 浏览: 89459 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

解决 MySQL server has gone away

阅读更多
#应用程序(比如PHP)长时间的执行批量的MYSQL语句。执行一个SQL,但SQL语句过大或者语
#句中含有BLOB或者longblob字段。比如,图片数据的处理。都容易引起MySQL server has gone away。


'''
mysql> show variables like '%wait_timeout%' ;
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| innodb_lock_wait_timeout | 50    | 
| table_lock_wait_timeout  | 50    | 
| wait_timeout             | 28800 | 
+--------------------------+-------+

mysql> show variables like '%max_allowed_packet%';
+--------------------+---------+
| Variable_name      | Value   |
+--------------------+---------+
| max_allowed_packet | 1048576 |
+--------------------+---------+
'''
cur.execute('set global innodb_lock_wait_timeout = 2880000')    # 语句执行间断时间
cur.execute('set global wait_timeout = 288000')                 # 最大等待时间
cur.execute('set global max_allowed_packet = 2880000')          # 上传大小
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics