Elvis has left the building! (or so MySQL says...)
Probably one of the most useless database errors I have ever come across (besides the "Catastrophic Failure" I sometimes seem to generate in SQL Server), is "The MySQL Server Has Gone Away".
Really? Where did it go? Is it coming back anytime soon, because I've got work to do.
As it turns out, this error could be caused by a number of things. According to the MySQL 5 documentation, it could be anything from a server timeout, to DNS problems, to trying to run a query that's too large. I'm not sure why they would have such a generic error for such a broad range of problems, though. Maybe the MySQL developers just decided to group a bunch of stuff under this error because they didn't feel like writing individual error messages, but a more descriptive error would have been nice. Even something like "Your Request Timed Out" or "Can't Connect To Server".
I eventually discovered what was causing my error. I was indeed trying to run a large query. I use the SQLyog Community Edition as a MySQL GUI. It's great for your basic DB stuff. In this particular situation, I had backed up one of my production DBs and was trying to restore it to my Dev machine. Every time I tried to restore the DB, I got the all encompassing "MySQL Server Has Gone Away" error, which is just what you want to hear when restoring a database. Apparently, when I backed up the DB I had selected the "Create Bulk Insert Statements" option. One of the tables in the DB had about 100,000 records in it, which in turn created a pretty large query when trying to use a bulk insert.
So, this was pretty easy fix. I just made another backup of the DB and made sure "Create Bulk Insert Statements" was NOT selected, and then was able to restore the DB without any problems.

