## Increasing MySQL Packet Maximum Size

In the process of uploading a massive CSV file to my Django application my session data are getting pretty big. As a the result I’m getting these errors:

• (1153, "Got a packet bigger than 'max_allowed_packet' bytes") and
• (2006, 'MySQL server has gone away').

The second error is potentially unrelated.

After some research it became apparent that the source of the problem is my max_allowed_packet setting. A quick check to find the current value:

That’s 16 Mb, but evidently not enough! It’s a simple matter to increase this limit. Just edit /etc/mysql/my.cnf (you’ll have to be root to do that!) and add the following:

Then restart MySQL.

Check that the limit has increased.

That solved the problem for me. If the problem persists then you might need to increase the limit further.