Fixing MySQL max_allowed_packet error in MAMP

If you get a packet bigger than ‘max_allowed_packet’ bytes error when importing into a MySQL database on a MAMP system, you need to edit your max_allowed_packet variable. It defaults to 1MB.

There are two ways to do this:

  • Create a my.cnf file and set the variable.
  • Add --max_allowed_packet=32M to /Applications/mamp/bin/startMysql.sh. Restart MAMP.

The latter method is easier but if you’re going to be editing other variables it’s best to create a my.cnf file. MAMP ships with five my.cnf configuration files.

You should be safe with my-small.cnf

/Applications/MAMP/Library/share/mysql/my-huge.cnf
/Applications/MAMP/Library/share/mysql/my-innodb-heavy-4G.cnf
/Applications/MAMP/Library/share/mysql/my-large.cnf
/Applications/MAMP/Library/share/mysql/my-medium.cnf
/Applications/MAMP/Library/share/mysql/my-small.cnf

Copy it to /Applications/MAMP/Library/ and name it my.cnf.

Choose one that works for you and copy it to /Applications/MAMP/Library/my.cnf. Find the max_allowed_packet = 1M line and change it to 32M (or whatever you prefer). Save the file and restart MAMP.

Phew.

One Comment

  1. Posted Nov 5, 2009 at 8:50 am | Permalink

    When using MAMP Pro, I believe it is important to make note, when in the MAMP Pro App, that by going to: File->Edit Template->MySQL my.cnf is the preferred method to make this change.

    A shortcut to access this file while in MAMP Pro is command 2.

    Thanks for the insight, this post helped me in resolving an issue I had with a large db import.

Post a Comment

Your email is never shared.

Comment moderation is enabled. Your comment may take some time to appear.