Mysql Server Has Gone Away

while hacking around in wordpress i encountered an annoying error: “Mysql server has gone away”.

the reason for “mysql server has gone away” in my case has been a too large sql query. while the content field for options in wordpress is defined as longtext (~2^32 bytes), the connection between php and the mysql server has a much smaller restriction: max_allowed_packet. in my case this was set to 1 mb (afaik, the default value). the option table entry is clearly above (~2mb). i figured this out after some debugging using your queryWithReconnect function. after setting max_allowed_packet to 16M in the [mysqld] section in my.ini, everything worked flawless.

if this doesn’t solve your problem, try the workaround by rob.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: