Drupal: MySQL server has gone away

User login

The other day I was working on a website, when the following error came up out of the blue:

PHP Warning: MySQL server has gone away
query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'MySQL server has gone away\nquery: SELECT data, created, headers, expire FROM cache WHERE cid = 'menu:0:en' in /home/hamburgi/public_html/orvwatch/includes/database.mysql.inc on line 121.', 2, '', 'http://www.mysite.com', '', 'myIP', timestamp) in /home/mysite/public_html/drupalsite/includes/database.mysql.inc on line 121

The above was appearing a number of times. With a quick google search I found this: http://dev.mysql.com/doc/refman/5.0/en/gone-away.html, letting me know that max_allowed_packet needed a higher value.

Luckily there is a very nice module out there (kudos) that allows a solution without messing with the my.ini file.
This is the Drupal Tweaks that allows us to override a number of PHP settings and database settings.

Using that I changed the value of max_allowed_packet and the error disappeared.

However, due to the aforementioned problem, I had no access to the admin section - I was locked out. Logging in the database, I disabled the Update core module by setting the status to 0. This removed the error message and then I was able to see my admin drupal menu :)

Tags: 
Drupal 6