Home

Mega Computer Solutions

Leave IT to us...

Main Menu

  • Home
    • Introduction
    • About Us
    • Company Profile
    • Brochures
  • Products
    • Order Online
    • Promotions
  • IT Solutions
    • Mega Firewall
    • Mega Managed Desktop
    • Mega Office Communicator
    • Mega IP Camera
    • Mega Managed IT Solutions
    • Mega Vtiger CRM
    • Onsite Computer Repair & Services
    • Kaspersky Anti-Virus
  • Blog
    • Experiences
    • How Tos
    • Reviews
  • Forum
    • Newbies
  • Wiki
    • Internet
    • Linux
    • Windows
  • Support
    • Drivers & Softwares
  • Contact Us
    • Inquiry Form

 

Home Blogs admin's blog

User login

Image CAPTCHA
Enter the characters (without spaces) shown in the image.
  • Create new account
  • Request new password

Navigation

  • Check Orders!
  • Blogs
  • Create content
  • Recent posts

Counter

  • Site Counter: 355,365
  • Published Nodes: 105
  • Your IP: 38.107.191.92
  • Since: 2009-05-17

Warning: MySQL server has gone away query

admin's picture
Submitted by admin on Fri, 09/10/2009 - 17:39
  • Experiences
Printer-friendly versionSend to friendPDF version

WE ARE BACK!

After some time offline, finally our site is back. God willing, we've solved one of our greatest problems with Drupal at that was the Warning: MySQL server has gone away query: issue. You know.... that very annoying blue or white page filled with gibberish about error with MYSQL and then some.

At first I thought that Drupal couldn't handle more than say 8 modules before doing is error page on me, but then I found out from the Drupal forums itself that it was due to the short connection time to the MYSQL database that causes this issue. Here's the solution from Ilia Penchev, member at Drupal.org:

I am posting here the 2 possible solutions for anybody who has the same problem, I hope this will be of help to somebody :

1. Quick approach (not recommended since it will leave you with no module update information)
Just go to Admin -> Site Building -> Modules and disable the 'Update status' module. Voala :) No more nasty MySQL warnings and error messages.

Anyway you will be left without actual information on any new updates or new major versions for your Drupal and modules.

2. The real fix (requires hacking of 2 Drupal core files)
Here is the real solution, it will require you to get hands dirty, but will fix your problem.

First make a backup of these two files - just download them to some directory so you have them just in case:
includes/database.mysql.inc
includes/database.mysqli.inc

Now you need to edit these two files (I edit them directly on the FTP server, but you can make additional copies locally, edit them, save and then upload back)

Add the following lines of code (on a new line, as explained):
In includes/database.mysql.inc, at the end of function db_connect(), under the "SET NAMES" line:

 

 

mysql_query('SET SESSION wait_timeout = 60', $connection);

In includes/database.mysqli.inc, at the end of function db_connect(), under the "SET NAMES" line:

mysqli_query($connection, 'SET SESSION wait_timeout = 60');

Now you should get no more MySQL errors.
If you increase the number of istalled modules on your Drupal you may need to increase the timeout from 60 to a bigger value, for example 90, but I seriously doubt it will be ever needed.

The idea of all this is that the update module will require more and more time to check for updates for the increasing number of installed modules on your Drupal site. At some point this time will exceed your server's default value for timeout and this causes MySQL "server gone away" errors.

On many webhosting companies' servers this timeout is set to a very low value (too conservative) and that's why so many people are facing this problem.

 

 

 

I hope this solves the problems for all our Drupal brethren out there. Have fun!!

  • admin's blog
  • Add new comment

Who's online

There are currently 0 users and 16 guests online.
Call us anytime: (Office) 1700-80-6342 / 012-6571463 / 019-2248416
RoopleTheme
Powered by Ubercart