MySQL server has gone away error fix for Magento

Today I wanted to test a tiny shell script, that didn’t do such magic stuff. It only generates a few websites, stores and storeviews and associates approximately 200 products to 4 websites. When I ran it locally I had no problems at all. But on the staging server I got the following error message when running the shell script. That’s why I had to fix this “MySQL server has gone away” – Error:

PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away' in /var/www/vhosts/topsecret.host.com/httpdocs/releases/36/mage/lib/Zend/Db/Statement/Pdo.php:228

The solution for the “MySQL server has gone away” – error

To solve the problem, I had to change the following value in my MySQL configuration file (/etc/my.cnf)

max_allowed_packet=33554432

This sets the allowed message package size to 32 MB.

Afterwards I had to restart the MySQL demon:

$> service mysqld restart

On some systems it can also be done via phpMyAdmin.

Further information

You can find more information about this MySQL setting on:

http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_max_allowed_packet

and

http://dev.mysql.com/doc/refman/5.7/en/packet-too-large.html

1 thoughts on “MySQL server has gone away error fix for Magento

Leave a Reply

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

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.