开发者

MYSQL server has gone away

开发者 https://www.devze.com 2022-12-13 01:28 出处:网络
I am using WAMP server for my web application . Sometimes I see this General error: 2006 MySQL server has gone away开发者_如何学Python\'

I am using WAMP server for my web application . Sometimes I see this General error: 2006 MySQL server has gone away开发者_如何学Python'

I am updating the MySQL database through PDO PHP.

Any suggestions to avoid this ?


Try to debug the problem. This can be caused by any number of things. Commonly there are:

  • The MySQL server crashed
  • A comms problem between the client and server
  • Abusing the client library in a way not intended, perhaps sending commands out of order or sending junk through the socket.

Last time I used it the PDO driver was quite flakey and it was possible to create the last case.

If the comms problem is likely in production, your application should reconnect and retry the transaction.


one possibility:

open your mysql/bin/my.ini, change

max_allowed_packet = 1M under both [mysqld] and [mysqldump]

to

max_allowed_packet = 100M


mysql_connect from php has a parameter name client_flag. You need to set this one, if your script lasts more than mysql server wait_timeout

MYSQL_CLIENT_INTERACTIVE Allow interactive_timeout seconds (instead of wait_timeout ) of inactivity before closing the connection.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号