How to Fix MySQL Error 2006: “MySQL server has gone away for the query”

I use Mantis at work (and at play) to manage bug and issue tracking. If you’re not familiar with it, I highly recommend checking it out.

So recently, I wanted to attach a large file (10MB wowzers!) to one of my bugs. When I attempted the upload, however, Mantis decided to throw an error at me suggesting that the max upload file size in PHP was preventing it from uploading the file. So, I loaded up php.ini and updated the two applicable lines:

post_max_size = 15M

and

upload_max_filesize = 15M

Woohoo! Ok, let’s upload the file now…

Database query failed. Error received from database was #2006: MySQL server has gone away for the query

What the heck!? Where did it go? MySQL, why have you forsaken me!?

So, after a bit of searching it turns out it’s related to the packet size setting in my.ini.

To fix it, load up your my.ini and find “max_allowed_packet”. Set it to whatever you set in your php.ini.

For example:

max_allowed_packet = 15M

Hopefully that’ll fix your issue!


Be Sociable, Share!

Leave a Reply

%d bloggers like this: