Debugging Wordpress SQL Import Errors

Every once in a while you find yourself doing something weird - in my case, trying to debug SQL import errors. I wrote this trial up for posterity and in case I would ever struggle with this again.

The Error

Maybe it's because I don't much about SQL, but the server error cracked me up.

MySQL said:
#2006 - MySQL server has gone away.

Like, really? Will it come back??

Anyways, what it means is the database is timing out trying to import the file. Rather than trawling through StackOverflow using that as a search phrase, instead I decided to try everything else.

The Struggle

First I tried a bunch of stuff that didn't work for me, but may work for someone else struggling.

  • I changed the file extension from .gz to .sql.gz
  • I downloaded and installed BigDump
  • I checked that the character encoding was set to UTF8
  • I restarted the servers

A Glimmer of Hope

Finally I had some success by tinkering around with the actual MAMP configuration files.

Didn't Work

Editing my.ini (also known as my.cnf) in the bin files so that my max_allowed_packet = 64 MB and the wait_timeout = 1000 & then restarting.

Did Work

In the top-level of phpMyAdmin, there's a tab called Variables. In that tab there is a big table of variables (I know, shocking). From there, edit max allowed packet to a bigger number.

After doing that, I restarted the servers and finally I had the sweet satisfaction of my database uploading.

IMPORTANT. I can't guarantee any of this, especially for live servers.

Anyways, hopefully this will help others, or at least be a handy reference when I have to reimport a database and get stuck again.