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/

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)


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:


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.