Quote from http://dev.mysql.com/doc/refman/5.0/en/gone-away.html:
The most common reason for the MySQL server has gone away error is that the server timed out and closed the connection.
[...]
Some other common reasons for the MySQL server has gone away error are:
* You (or the db administrator) has killed the running thread with a KILL statement or a mysqladmin kill command.
* You tried to run a query after closing the connection to the server. This indicates a logic error in the application that should be corrected.
* A client application running on a different host does not have the necessary privileges to connect to the MySQL server from that host.
* You got a timeout from the TCP/IP connection on the client side. This may happen if you have been using the commands: mysql_options(..., MYSQL_OPT_READ_TIMEOUT,...) or mysql_options(..., MYSQL_OPT_WRITE_TIMEOUT,...). In this case increasing the timeout may help solve the problem.
* You have encountered a timeout on the server side and the automatic reconnection in the client is disabled (the reconnect flag in the MYSQL structure is equal to 0).
* You are using a Windows client and the server had dropped the connection (probably because wait_timeout expired) before the command was issued.
etc.