Jul 17

Fix MAMP Error: "General error: 2006 MySQL server has gone away"

Wed, 07/17/2013 - 19:46 — peter

While working on a local copy of a Drupal site I am helping develop, I ended up hitting the following error:

General error: 2006 MySQL server has gone away: SELECT ff.* FROM {filter_format} ff ...

Ugh! Now what?! We need to change a setting on MySQL that ships with MAMP. As it turns out, the default max_allowed_packet is set to 1M and it needs to be higher. Changing that to 100M did the trick for me. Locate your my.cnf file and add the following setting under the [mysqld] section:

max_allowed_packet = 100M

Hang on a sec! Where is that my.cnf file?! Well... its location varies. If you have MAMP, then it is at /Applications/MAMP/conf/my.cnf, and if you have MAMP PRO, then you edit the file by going into MAMP, then File -> Edit Template -> MySQL my.cnf. Edit the file, restart MAMP and you are good to go.

To make my life easier, what I like to do is add the following line at the end of the my.cnf file:

!includedir /Users/peter/mysql

Then create one or more files into the /Users/peter/mysql folder with my optimizations. This way I don't need to go hunting for that my.cnf file again.

Easy Peasy!

-PCP