max_allowed_packet error on MySQL

I was doing some work where I needed to run some heavy queries on a database using the production data. Naturally I made a backup of the database and the plan was to restore it to my local MySQL instance on my development box and then run my tests. I hit a couple snags, and in an effort to document everything that I run into that requires some gumshoeing here is how I fixed it.

I read a bunch of people saying you could use –max_allowed_packet=100M in the command line but I had no luck with this. I also found some people who said you could edit my.cnf to put the setting there but the location and existence of this file appears to be different per the platform and installation method for MySQL. The end result is to update the setting directly at the mysql prompt. So:

1
2

mysql> SET GLOBAL max_allowed_packet = 16 * 1024 * 1024;

Name

Email

URL

Comment