MySQL Server Has Gone Away Error - Cause & Solution

The MySQL Server has gone away error can happen when trying to restore a database. There are a few possible causes for this and one of the most likely is that the database is very big in size and the packet size in MySQL is not big enough.

The solution is to increase is the packet size in the my.ini file. The default is 1Mb. Change it to something like 24M.

[mysqld]
max_allowed_packet=24M

If you do not have access to the my.ini file, then you will need to contact your host.

If you are restoring a database locally using WampServer or similar, you can easily access the my.ini file. Just click on the WampServer icon on the toolbar, navigate to MySQL and then my.ini. The my.ini file will open as a notepad file. If max_allowed_packet does not exist, then add it after [mysqld]. Do not forget to save the file!

When you change (or add) the max_allowed_packet, you will need to restart MySQL in order for the changes to take affect.

Enjoy this article?

Get my best content on Javascript, CSS, PHP & Git before anyone else and special bonuses.

Get started

Add new comment