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.

4 Responses to Fixing MySQL max_allowed_packet error in MAMP

  1. 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.

  2. Hi Chris -

    Thanks so much for this mini-tutorial. It solved my MYSQL import problem on the first try.

    Thanks again,

    Ken

  3. Glad to help, Ken!

  4. Thanks! It helped me a lot. Eva

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">