Drupal 7 MySQL Server has Gone Away

I was working on a new Drupal 7 site.  Everything was working well with the site, and it was time to put the theme together.

I decided to use the Omega theme which is a full featured theme.  The installation of the Omega theme calls for a bunch of new modules to be installed.  I got everything installed, and I started to use the theme to design the site, when I got this error:

"General error: 2006 MySQL server has gone away"

Huh? The error was repeated several times along with a bunch of not that helpful verbage.  The site shut down.  This was suddenly, and I didn't do anything, configuration wise, that I could back out to get the site back.  Rats, here we go again, dead in the water.

I restarted my WampServer.  Everything started up fine.  I went back to the Drupal site, and got the same error message again.  The MySQL Server has gone away.

Well, this one took me about an hour to sniff out, and it turned out to be a MySQL configuration error, not a Drupal 7 error.

Drupal modules make calls to the database to get the data needed for the current screen.  The MySQL database sends the data back in packet of data. As the number of installed Drupal modules increases, the size of the packet increases.  If the packet exceeds the MySQL maximum allowed packet size, MySQL shuts down, your entire site shuts down, and you get the above error message.

What I didn't realize was there is a packet size limit set in the MySQL configuration file, my.ini.  Open up the my.ini file via your Wampserver > MySQL menu.  Under the heading "# The MySQL Server", you'll find max_allowed_packet = 1M.  Change the 1M to 32M, and the error message goes away, your site is back up, you're back in business.

A caution here, there is another max_allowed_packet setting later in the my.ini file under the heading [mysqldump]; changing that setting will not get rid of the error.

This was the first time I've ever had a problem with a MySQL configuration setting.  In all the times I've used the WampServer for creating sites, I've never even looked at the MySQL my.ini file.  There's a first time for everything.

Comments are closed.