Having just moved quite a large installation to a MySQL database I have encountered the following error when connecting to the MySQL server:
ERROR 2006 (HY000): MySQL server has gone away
After looking at countless solutions and none working (many say that the max_packet value has to be increased), I found a MySQL engineer stating that is has to do with the timeout values which could be 10 or 20 (by default).
Indeed, the problem was solved on our servers with a higher value for interactive_timeout and wait_timeout. You can set these values (and many others) in the my.cnf file.