General error: 2006 MySQL server has gone away This is the error I am suddenly getting.

Additional uncaught exception thrown while handling exception.

Original
PDOException: SQLSTATE[70100]: Unknown error: 1317 Query execution was interrupted...my query

Additional
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away...my query


After doing some research it sounds like a custom module, which I have made, is attempting a query which is too big. A solution that seems to work for a lot of people is this:


Open my.ini
Change "max_allowed_packet" from "1m" to "16m" (or larger)
Save my.ini and restart MySQL


However, I am on a shared server, so I cannot edit my.ini, and although my provider has confirmed to me that the value is set to 1M, they won't increase it.

I also tried adding this: ini_set('mysqli.reconnect', 'on'); to settings.php. It didn't solve the problem.

Does anyone know of a another solution, or work around?

Thanks.
Shared hosting companies do not give away the SUPER privilege. If you have it, you can easily set max_allowed_packet  to 512M by just running this :

mysql&gt; SET GLOBAL max_allowed_packet = 1024 * 1024 * 512;


No restart is required. Then, all incoming connections thereafter can have a 512M packet.

You cannot do this:

mysql&gt; SET max_allowed_packet = 1024 * 1024 * 512;


because you get

ERROR 1621 (HY000): SESSION variable 'max_allowed_packet' is read-only. Use SET GLOBAL to assign the value


The only alternative I can think of is to switch to Amazon EC2 and install MySQL there. That way, you can have free rein to edit my.cnf/my.ini and have the SUPER privilege.