Submitted by Jeff Geerling on August 16, 2011 - 9:57am
I've been getting errors like General error: Can't create/write to file, Error 2006: MySQL server has gone away, and other similar PDOExceptions and errors from time to time while developing on my Mac using MAMP Pro (this seems to happen more often with Drupal 7 sites than Drupal 6, for reasons I know not). I've noticed a few other developers are getting these errors too, and almost always on local environments as opposed to live servers.
I found that the easiest way to deal with them is by giving MySQL a nice buffer of memory via the max_allowed_packet and innodb_buffer_pool_size settings. Just bump those up to 256M or higher, and the errors above should go away. (In MAMP Pro, just go to File > Edit Templates > my.cnf, and search for those variables. Uncomment the innodb_buffer_pool_size variable if it's commented out.
Typically this only happens if you're working with rather large databases, or if you're doing things like clearing all caches with a low max_allowed_packet size. Some people drop the entire database and reimport, but that seems like overkill to me—especially since I can always throw more RAM at a problem!
Further reading: MySQL has gone away [MySQL Reference Manual]
Comments
Thanks for the suggestion.
Permalink Submitted by Jon (not verified) on August 16, 2011 - 3:53pm.
Thanks for the suggestion. This error was starting to drive me crazy. For me it seemed to happen when I was adding fields to a content type.
It seems to happen most often
Permalink Submitted by Jeff Geerling on August 16, 2011 - 3:55pm.
It seems to happen most often when larger caches are cleared, or when using things related to the Entity API or Token API, in my experience.
Check out my personal website: www.lifeisaprayer.com.
Thanks to your post I'm able
Permalink Submitted by Linda (not verified) on September 15, 2011 - 3:43am.
Thanks to your post I'm able to get rid of this annoying error. It appeared every time when I was adding fields to a content type. Thanks for sharing!
Great advice!!! thank you ...
Permalink Submitted by Marian Bîrlădeanu (not verified) on March 21, 2012 - 1:40pm.
Great advice!!! thank you ... just saved my life with some offline drupal 7 development project!
Add new comment