Locally I get "MySQL Server has gone away" -- any help appreciated

SteveTurnbull - October 24, 2007 - 22:57

I've just downloaded a drupal site I'm working on which functions perfectly on the live server.

But on my local machine every query gives the "MySQL Server has gone away".

I'm good with drupal (definitely not a n00b) but not so good with servers so I have very little clue as to what could be causing this. I've read the MySQL docs on the error without enlightenment, read all the drupal references to it. No help there.

I believe I have the usenames and passwords set-up right because drupal tries to display the front page but in doing so I'm getting 50-60 of these errors, apparently one for every attempted MySQL query.

Warning: MySQL server has gone away query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', '<em>MySQL server has gone away\nquery: UPDATE cache_views SET data = &amp;#039;a:4:{s:6:\\&amp;quot;tables\\&amp;quot;;a:166:{s:17:\\&amp;quot;nodefamily_parent\\&amp;quot;;a:3:{s:4:\\&amp;quot;name\\&amp;quot;;s:10:\\&amp;quot;nodefamily\\&amp;quot;;s:4:\\&amp;quot;join\\&amp;quot;;a:3:{s:4:\\&amp;quot;left\\&amp;quot;;a:2:{s:5:\\&amp;quot;table\\&amp;quot;;s:4:\\&amp;quot;node\\&amp;quot;;s:5:\\&amp;quot;field\\&amp;quot;;s:3:\\&amp;quot;nid\\&amp;quot;;}s:5:\\&amp;quot;right\\&amp;quot;;a:1:{s:5:\\&amp;quot;field\\&amp;quot;;s:10:\\&amp;quot;parent_nid\\&amp;quot;;}s:4:\\&amp;quot;type\\&amp;quot;;s:5:\\&amp;quot;inner\\&amp;quot;;}s:7:\\&amp;quot;filters\\&amp;quot;;a:1:{s:9:\\&amp;quot;child_nid\\& in C:\wamp\www\includes\database.mysql.inc on line 172

The error is being triggered in the _db_query function, not really a surprise, so essentially every attempt to run a query says the server has gone away (although it's still there).

Also attempting to access any other page generates a 404 Page not found (even admin).

I went into the system table and switched off the Dev and Watchdog modules (maybe not the greatest idea) and also removed the dev variables to stop the debugging part. But it made no difference anyway.

I'm wasting time trying to get this running when I should be developing code. Any ideas?

Steve

no help, maybe a pointer

tm - October 25, 2007 - 02:29

try searching drupal.org for the string "MySQL server has gone away" (with the quotes). hopefully someone else's solution will be yours, too.

not being sarcastic, really. just that everyone's situation is just, well, different.

added: just thinking about it; you are trying to migrate a prod install to local. you are not even getting far enough to get "white screens". the error indicates nodefamily might be a part of it? can you get to the database via phpmyadmin? wonder if you can temporarily disable that module.

sorry, lost track of the handbook page on moving between servers; one of the steps was to clear the cache. also assuming that space is not an issue. you may wish to disable local antivirus until things get going (overhead); disconnect from the world if you do that.

A small part of the problem...

SteveTurnbull - October 25, 2007 - 12:08

(I'd already read everything on the drupal website about this error -- no help.)

OK, a small part of the problem was that the .htaccess hadn't downloaded, that's why I couldn't access any other pages. But no I'm not getting white screens -- they wouldn't scare me :-)

What I'm getting is pages full of "MySQL server has gone away" because that's what every query is generating.

Yet Drupal doesn't say it can't find the server, which you'd expect if the username, password or database names were wrong. For example (using MySQL administrator) I remove all the privileges for Drupal, I get the start-up error saying that drupal can't access the database, if I give it the privileges back then it happily generates a hundred "MySQL server has gone away".

I have cleared all the caches. Antivirus is not an issue (this machine is isolated from the web.)

FIXED. SEE BELOW....

awesome

tm - November 7, 2007 - 01:37

whatever made you look at that as a solution (indicators)? hints?

good that you got it going, in any case.

added: were you looking at http://dev.mysql.com/doc/refman/5.0/en/gone-away.html as a troubleshooting reference?

Maybe a module causing the problem

Corey Smith - October 25, 2007 - 02:50

I had the same problem earlier when trying to load the Poormanscron. Once I disabled the module, problem went away.

Corey Smith

Thanks but we're not using

SteveTurnbull - October 25, 2007 - 08:33

Thanks but we're not using poormanscron.

The Solution

SteveTurnbull - October 25, 2007 - 12:07

Fairly simple cause: the packet size on MySQL wasn't big enough and since this application uses big queries and masses of data the local version of MySQL just gave up and refused to do it.

In "my.ini" you want:

[mysqld]
max_allowed_packet=24M

(or whatever, I chose a ludicrously big number.)

Steve

max_allowed_packet=24M

askttt - November 6, 2007 - 15:29

Could there be an alternate way of fixing the problem. I don't have acces to my.ini with Godaddy.

Same problem here... I'm

Purazar - November 6, 2007 - 21:40

Same problem here... I'm hosting with Go Daddy as well, and I have no way of increasing the packet size. Any other solutions to this problem?

MY SQL Gone away

Shyamala - November 15, 2007 - 04:29

Tried increaing packet size/wait_timeout wiht no effect. WHen I create a long CCK I get the MySQL gone away error. Have been stuck with this problem for over a week, any help is appreciated.

Summary of the associated my.ini file:

| max_allowed_packet | 1048576
| slow_launch_time | 2 |
| slow_query_log | OFF |
| slow_query_log_file | D:\server\mysql\Data\meenambica-slow.log
version | 5.1.22-rc-community
| wait_timeout | 28800

Thanks
Shyamala
Team Leader Netlink Technologies Ltd.

fix on shared hosting

g76 - May 6, 2008 - 10:34

this worked for me. I am on a shared hosting account, no access to mysql settings, but this seemed to fix it:

http://drupal.org/node/227445#comment-770663

also, disable syslog and database logging.

gideon

trying to do?

jeditdog - June 9, 2008 - 13:54

are you just using basic drupal functionality at GoDaddy? I ask because I'm there too and you're scaring me :)

I'm wiling to run some tests there if you let me know what it is you're trying to do there.

You're not trying to connect @localhost are you though? My experience is that GoDaddy hosts the DB on a seperate server.

-------------
The main man of MMC :)

where is my.ini

lasarletter - December 26, 2007 - 16:40

where is my.ini in the drupal system?

mysql

tm - December 26, 2007 - 18:18

this is not a drupal file. my.ini is the mysql configuration file; it is usually in the root of your mysql installation.

Thanks

kenorb - March 20, 2008 - 09:51

Thanks, it works.

Thanks

Michelle - April 1, 2008 - 15:08

I've been struggling with this, too. I ended up setting it to 48 and also putting it in the "client" section and finally the errors went away.

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

Workaround?

Cellarstudios - February 27, 2008 - 19:54

Is there a work around for this issue without having to edit root .ini files? I am hosted on Godaddy.com and I too can not reach these files to edit them.

I am getting the same error as listed above.

No other way...

SteveTurnbull - March 5, 2008 - 14:07

Sorry guys, the problem is that Drupal builds *massive* PHP files out of all the separate files.

In fact it can get even worse than this. The problem might not solve by just changing that value, sometimes you have to get into the server because that can override the .ini setting.

Which happened on my latest job.

hosting

ahoria - March 10, 2008 - 21:40

what would be a good shared host to cope with issues like this?

thanks

One that supplies Drupal as

SteveTurnbull - March 20, 2008 - 10:06

One that supplies Drupal as part of its package perhaps.

In the UK I use purleyhosting.com, small company, friendly and they use Drupal themselves.

My issue was max_allowed_packet

torelad - April 12, 2008 - 08:24

I ran into this problem running XAMPP on a Windows XP configuration.

Increasing max_allowed_packet in the [mysqld] from 1M to 16M (max_allowed_packet = 16M) in xampp\mysql\bin\my.cnf and restarting MySQL solved my instance of the problem. I may have been able to get away with a smaller increase but I didn't experiment.

wait_timeout fixed it for me

brunodbo - May 13, 2008 - 14:08

Had the same problem. Increasing max_allowed_packet didn't help.

Changing the wait_timeout variable in /var/lib/mysql/my.cnf did help. It defaults to 15 (seconds). Increased it to 45, and MySQL didn't go away anymore.

--
Don't hate the media, be the media -- www.indymedia.be

I can't find the files in

newbii - June 7, 2008 - 11:01

I can't find the files in phpmyadmin and ftp. Where can I find my.ini and my.cnf? I use shared hosting.

I'm afraid you probably

SteveTurnbull - June 9, 2008 - 10:14

I'm afraid you probably don't. On a shared host you may be limited. You need to ask your hosting company about it.

I had this problem and

Slacky08 - June 19, 2008 - 09:07

I had this problem and managed to fix it thanks to the following article which gave the same information here, except I didnt know how to do it in XAMPP on Windows XP install.

http://minorpoint.blogspot.com/2007/09/mysql-server-has-gone-away.html

any relation with connection speed?

newbii - June 22, 2008 - 09:59

I only get this error if I configure the block module. But, when I use faster internet connection to configure the blocks, I don't get this error.

It is a strange effect for me. Please let me know what you think about this.

Be careful with your hosting provider...

bigmotard - June 26, 2008 - 14:24

FYI

I have my drupal site hosted on HostICan (www.hostican.com) hosting provider (aka HIC). HIC Team refused to change the parameter of mysql 'max_allowed_package' to increase the buffer size between Drupal and MySQL in a shared environment. They forced me to upgrade to a Virtual Private Server hosting package to allow this config modification.

To let you figure out my drupal site resources usage and help you decide which hosting package you will need to hire when using Drupal on HostICan read the following:

- My site has less than 100 registered users.
- My site has never had more than 15 concurrent users.
- My site AWStats say that from June the 1st to June 26th we've had an average of 141 visits per day with a bandwidth consumption of 160MB per day.

Clearly, in my honest opinion, this is a real little Drupal installation. Therefore we can conclude that HostICan is not prepared to host Drupal sites on their Base Hosting package, be careful.

HostICan has a good system technologies environment, but be carefull if you are trying to mount a "real" drupal site on their hosting. If you hire a Base hosting, you will only be able to "play" with drupal...

Regards

P.s: This post is not to make any preasure on HostICan team nor being dissuasive with new HIC users. My only intention is to inform all of you about what you will need to hire if you plan to build a Drupal site on HIC.

Reasons why a hosting company would not increase this

graper - August 4, 2008 - 20:39

Not that I know the real reason why HIC would not do this, I do know a good reason why any hosting company would not want to increase this on a server devoted to shared hosting.

Most hosting companies that allow for shared hosting accounts just about give away bandwidth and storage space. Seems that you can get account for as low as $5.00 a month and get just gigs and gigs of storage like 300gigs or more, they also give you gigabytes or terabytes of bandwidth each month. From a marketing perspective it's very appealing to a website owner. What truly matters, especially with database driven sites, is CPU cycles and memory. The bigger the database the memory footprint you'll leave, also the same with mode code. Consider drupal, the more modules you enable the bigger the memory footprint as all the code of every module gets loaded and executed. The more code, or even complex looping of code, will take more CPU time. If you have a shared account and try to run more then 50 domains on that account because they say you can have "Umlimited Domains", well guess what, if you start eating too much ram or CPU cycles, they can just kill off your processes. This happened to use on a shared account. We soon realized that almost every hosting company had the same scenario.

While MYSQL documentation says "It is safe to increase the value of this variable because the extra memory is allocated only when needed. " link it still has some impact on ram allocation and therefore a hosting company has to take it into consideration.

The other real reason that they deny this change is that they are in control and want more money out of you for more options :)

Granville
Kirkham Systems

 
 

Drupal is a registered trademark of Dries Buytaert.