Solving Drupal error: PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

drupal-logo

The problem

After downloading a Drupal project I am working on, and importing its database I got this kind of message related with a PDO Exception:

Additional uncaught exception thrown while handling exception.

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = :source AND s.context = :context AND s.textgroup = 'default'; Array ( [:language] => es [:source] => Configure how content input by users is filtered, including allowed HTML tags. Also allows enabling of module-provided filters. [:context] => ) in locale() (line 720 of /Applications/AMPPS/www/sites/drupal/modules/locale/locale.module).

 Solution

This is an issue related with the MySQL configuration, for solving it,
1) Go to your MySQL configuration file: my.cnf. In my case that file is in /Applications/AMPPS/conf (I use AMPPS on OS X Yosemite).
2) Look for max_allowed_packet parameter and increase it as in this example (you will usually find this parameter twice in my.cnf file).
// My default value
max_allowed_packet = 1M

// The new value
max_allowed_packet = 256M

3) Restart your MySQL server.

I hope you find this post useful, see you next time!

Leave a Reply

Your email address will not be published. Required fields are marked *