Workaround for WordPress database error: [MySQL server has gone away] for different versions of WordPress
November 26, 2010 – If you would like a patched file for other versions of WordPress besides the ones listed here, you can email me at wpmysql at(@) robsnotebook.com and I will tell you my fee.
For those of you who have received the WordPress error message “WordPress database error: [MySQL server has gone away]”, I made a change to a WordPress PHP file that makes it so you will probably never get this error again.
There are several possible causes to getting this error. Further down in this article, I will describe what I think is happening and some things that you can do (other than this workaround) to diagnose and fix the problem.
Installing the Workaround
There are 2 workarounds, you can use either one of them, although one of them has better performance than the other.
- wp-db-x.y.z-workaround.phptxt
- The latest version of the workaround with the best performance. This latest workaround is available for all versions of WordPress that are listed in this article.
- wp-db-x.y.z-workaround-old.phptxt
- The original version of the workaround with less than optimal performance. Since I am no longer maintaining that version, I only have it posted for the versions of WordPress that I had originally posted it for. This workaround is based on the work of openadvent.
To install the workaround, download the “workaround” or “workaround-old” version of the wp-db…phptxt file, rename it to wp-db.php, and copy it to wp-includes/wp-db.php (overwriting the old file). You may want to backup the old file instead of overwriting it. You’ll need to do this each time you upgrade WordPress (a pain, I know), with the appropriate version of wp-db.php for that version of WordPress.
WordPress Versions not listed here
I can create them for you for a fee. Send email to wpmysql at(@) robsnotebook.com and I will tell you the fee.
WordPress 2.8.1
There was no change in wp-db.php from 2.8 to 2.8.1, so use the 2.8 file.
WordPress 2.8
Workaround wp-db.php
Original wp-db.php
WordPress 2.7.1
There was no change in wp-db.php from 2.7 to 2.7.1, so use the 2.7 file.
WordPress 2.7
Workaround wp-db.php
Original wp-db.php
WordPress 2.6.1
There was no change in wp-db.php from 2.6 to 2.6.1, so use the 2.6 file.
WordPress 2.6
Workaround wp-db.php
Original wp-db.php
WordPress 2.5
Workaround wp-db.php
Original wp-db.php
WordPress 2.3.3
There was no change in wp-db.php from 2.3.2 to 2.3.3, so use the 2.3.2 file.
WordPress 2.3.2
Workaround wp-db.php
Workaround-old wp-db.php
Original wp-db.php
WordPress 2.3.1
There was no change in wp-db.php from 2.3 to 2.3.1, so use the 2.3 file.
WordPress 2.3
Workaround wp-db.php
Workaround-old wp-db.php
Original wp-db.php
WordPress 2.2.3
There was no change in wp-db.php from 2.2.1 to 2.2.3, so use the 2.2.1 file.
WordPress 2.2.2
There was no change in wp-db.php from 2.2.1 to 2.2.2, so use the 2.2.1 file.
WordPress 2.2.1
Workaround wp-db.php
Workaround-old wp-db.php
Original wp-db.php
WordPress 2.1.2
Workaround wp-db.php
Workaround-old wp-db.php
Original wp-db.php
Why This Happens
When someone tries to view one of your WordPress web pages, the PHP code first opens a connection to the MySQL server. Subsequent queries to the MySQL server rely on the connection remaining open, and do not re-open the connection. If the connection to the server happened to have shut down before a query is made, then WordPress will display this error.
One reason that the connection may shut down is if it has been idle for “wait_timeout” seconds since the last access to the connection. “wait_timeout” is a system variable in your MySQL server configuration. I have created a tool to allow you to check the value of “wait_timeout”.
Tool for checking “wait_timeout”
Changing the “wait_timeout”
If your “wait_timeout” variable is small, and your CPU is heavily loaded, it may make it more likely that your connection to the MySQL server is shut down prematurely.
If your “wait_timeout” is too small, and you have admin access to your MySQL server, it is possible to change the default value of “wait_timeout” by editing a file such as /etc/my.cnf, and restarting your MySQL server.
If you don’t have admin access (you are on a shared host), there is a way to change the “wait_timeout” variable for the MySQL session, but you need to modify the wp-db.php file (either the workaround version or the original version).
To change the “wait_timeout” to 600 in the wp-db-x.y.z-workaround.phptxt, uncomment (remove the “//”) the line:
// $this->query("set session wait_timeout=600");
You can also change the wait_timeout in the original wp-db.php file (if you choose not to use the workaround) by adding the above query line for changing the wait_timeout variable into the wp-db.php source. The place to insert the line is inside the “__construct(…)” function after the closing brace ‘}’ of the “if (!$this->dbh) {” statement.
What the Workaround Does
The original workaround posted in this article (labeled “workaround-old” now) was originally conceived by openadvent. In that workaround, PHP code was added that would try to “ping” the mysql server before each query. If this ping was unsuccessful, then the workaround would try to reopen a connection to the MySQL server and then repeat the query. The connection would try to be reopened and queried 4 times before declaring a failure.
The newer workaround that I have on here now does not do this ping, giving better performance. Instead, it just tries to perform the query. If the query is successful, the PHP code continues on, and no new connection to the MySQL server is opened. If the query fails, the PHP code will try to reopen the connection and do another query. Just like the old workaround, the connection would try to be reopened and queried 4 times before declaring a failure.
Another Possible Fix
One person posted in the comments that by switching from PHP 4 to PHP 5, he was able to get rid of this error. Perhaps his PHP 4 implementation was running just slow enough that it was exceeding the timeout, and PHP 5 was running fast enough to avoid the timeout. When I originally encountered this error, I was using PHP 5, so switching from PHP 4 to PHP 5 may not solve the problem.
Hey, Rob,
Thank you! It has fixed the error in my blog.
Weki.cn
I think it worked for me, too. The admin site is still painfully slow, but I can get back into it for the first time in six hours.
I checked out WordPress version 2.2.2, and there is no change in wp-db.php from 2.2.1 to 2.2.2, so I added a note to use the 2.2.1 file for 2.2.2.
Heya Rob, thanks a ton for that fix. You really saved me from going through a lot of trouble! 🙂
hey, how about WordPress 2.3?
TQ
Fix for WordPress 2.3 was just added.
Thanks Rob! great fix for WP 2.3
& it seems fix for WP 2.2.1 also works fine for WP 2.3
Great job!
I wouldn’t recommend using the WP 2.2.1 fix for WP 2.3, since when I did the update, I noticed that they added some things into wp-db.php for WP 2.3.
heya Rob,
Thank you for the fix, i just applied it and it works just fine.
the strange thing in my case though that the error wasn’t sitewide, but was appearing on a single post only, my most recent post, and only with my comments and not other people’s, any idea why? 🙂
Rob – THANKS! for this. Worked like a charm on my 2.3 blog. You da man!
[…] file in version 2.1. Because I recently upgraded to WP 2.3, I applied the file fix again. It is at this site if anyone else needs […]
Thanks! I had applied the fix for version 2.1 and forgotten about it since it worked so well. Now that I am on Version 2.3 I have been getting some timeouts and the “Lost Connection to the MySQL Database” error, followed, of course, with the “gone away” error.
Hopefully I have fixed it by downloading your file to replace the one that came with 2.3.
Really appreciate your effort on this and have posted and linked to your fix.
-Will
Thanks mate! I’m using WP 2.3.1
[…] Investigando un poco he encontrado la solución. […]
Please don’t link to the fixed php files directly on your blog, since I do release new versions when there are new releases of WordPress (and I would also like to get the ad traffic). If you do want to link, use the one to this page: https://robsnotebook.com/wordpress-mysql-gone-away. Thank you.
[…] Download the fix here […]
Much thanks! I diffed the 2.3 v 2.3.1 wp-db.php file and except for a trailing line feed there was no difference. Your fix worked so far 🙂
The Flick photo page on my blog gone error when I upgrade the plugin to v0.93.1 which use database to keep the image cache in the DB. Your mod fixes the problem..
Thanks a lot
Kanok
[…] Yes, this error happened to me too. It seems there are plenty of hosters who just don’t bother configuring and tuning mySQL and this is definitely not quite a WordPress issue (at least I can’t believe it runs heavy queries when adding a new post), but there is a workaround Problem explanation and download link […]
[…] pingback […]
I used the 2.1.2 file for WP2.1.3 and it’s working so far.
Thanks!
mbm
[…] Origional complete article link with more details […]
[…] information get from : fix for wordpress database error […]
thanks 4 the fix.. now my blog can run smoothly back..
[…] created to the public for this issue. You may try visiting the following link for the resolution. https://robsnotebook.com/wordpress-mysql-gone-away Kindly let us know if the above link has solved your issue after you have replaced your […]
Thanks. I have been pulling my hair when this error shows up. I even phoned my hosting company but they say it’s not their end. Anyway, I took your suggestion and see if this fixes the problem!
[…] Fix for WordPress database error: [MySQL server has gone away] for different versions of WordPress – MySQL server has gone away wordpress error […]
I got exactly the same problem, but I have been running a very old version of WordPress – 2.1. I copied the 2.1.2 fix and replaced my wp-db.php with it, but i get an error message “Fatal error: Call to undefined function: hide_errors() in /home/lasermk/public_html/wp-includes/functions.php on line 913”
Any idea how to get round this? Many thanks in advance.
It seems that wp-db.php did change from WP version 2.3.1 to 2.3.2. I have posted the fixed 2.3.2 file in the article.
[…] ???????????????? Fix for WordPress database error: [MySQL server has gone away] for different versions of WordPress […]
[…] created to the public for this issue. You may try visiting the following link for the resolution. https://robsnotebook.com/wordpress-mysql-gone-away Kindly let us know if the above link has solved your issue after you have replaced your […]
[…] I upgraded to WordPress 2.3.2, I have noticed a really strange error. I am trying a fix found here, and this post is partly a test to see if it […]
Thanks mate… you’re my savior
Hi. Please CC me if you respond to this (you don’t have comment subscription).
I did this. And it works — thanks for this hack!
But I would additionally like to use “mysqli_” instead of “mysql_” functions for better MySQL 5 performance. Any way we can change that in just one file and be done with it, or are queries scattered all over?
http://trac.mu.wordpress.org/ticket/376 says:
07/24/07 16:07:35 changed by donncha
“Check your MySQL wait_timeout variable. What is it set to. It’s likely that it’s way too low. Try setting it to 600 or higher. The solution offered by the link above suggests not reusing an existing connection but that doesn’t make sense and would severely reduce performance on your server.”
Thanks Martin for that tip. Based on your suggestion, I just tried to find a way to find out what my MySQL wait_timeout variable is, but I haven’t figured it out yet. I’m sure if I kept looking, I’ll find it, but if you know it and can say how to do that, it would be great.
I altered the variable to value 600 in /etc/my.cnf – but you may be unable to change this on machines where you don’t have root access.
http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#option_mysqld_wait_timeout has the description for this variable. You may find this useful in discovering how to set the value interactively.
Thanks Martin. I don’t have root access, but I think I found a way to discover the value of my wait_timeout variable. I sshed into the server and executed “mysqladmin -u username -p variables”. It shows that the wait_timeout variable is 60. Do you think that this is too small?
I’ve also been meaning to change this “fix” (Hack really is the appropriate word). I originally just used openadvent’s idea to ping the connection to see if it is still open (and only reopening the connection if the ping is unsuccessful). I think a better way would be to just perform the query, and only open a new connection if the query fails. This way, the only penalty in performance is when the query fails. If the query is successful, there is no penalty. Someday soon I will make this change and do another post with it.
[…] was just looking at RobsNotebook.com and came across a really good solution to a common problem with […]
In a recent upgrade, 1and1 hosting has broken my site. This looks like the fix. However, I am at version 2.0.11. Has this been tested at that level, or will I need to upgrade to a later release of WP? Are there plans for 2.5?
skarld: The earliest version that I have done this for is 2.1.2 (I never tested any earlier version). One option for you if you do not want to upgrade is to make the changes yourself in your version of the wp-db.php file. You can look at what I have here as the original for 2.1.2 and the fix, and you can insert the changes yourself. I’m a little busy these days, otherwise I would look into making the change for you myself.
Thanks for the suggestion. It did not work.
My host suggested PHP5. Stating the following:
Try switching to PHP5. Scripts parsed in PHP4
use more memory than PHP5 in our systems. You can switch to PHP5 by
adding line below in your .htaccess file:
AddType x-mapp-php5 .php
It worked.
When I first got this error, I was using PHP5. I think it is a very sporadic error and only really occurs when your server is highly loaded (especially shared hosts). I would say that the error maybe only occurs 1% of the time, but when the condition that causes the error occurs, the workaround in this script will try to reconnect with the MySQL server.
[…] server has gone away]. Dan, oh thanks God for creating the creator of google, saya pun menemukan ini. And it shows the problem and the solution too.. Dan akhirnya bisa!! […]
[…] goodness the solution is not very hard. My hastyhost found this solution and helped me with the upload the first time round. Today, I had to do it myself, using WIFI in a […]
I rewrote the article and added a new workaround that does not do the ping – increasing the performance. The article also gives more information for diagnosing the problem, such as looking up the value of the “wait_timeout” MySQL variable, and how to change this variable.
I added the workaround for WordPress 2.5.
[…] must be something in WordPress itself that causes this error and I found a workaround for it here: Workaround for WordPress database error: [MySQL server has gone away] for different versions of Word… I did what it said to do and now my blog is back! *whew* __________________ Army Mom: New […]
[…] if you ever get an error like that then you need to get the workaround from Rob’s Notebook. It saved my sanity… it will save yours. It was very, very easy to […]
Rob.. thank you so much for this. I was about to pull my hair out. This saved my hair, sanity and my blog!
[…] UPDATE 2008.04.11????????????????wp-db.php????????????????????????????????????????????????? […]
[…] WP-DB ???????? MySQL ??? Ping MySQL ?????????? error-log […]
The db file of 2.5.1 is identical to that of 2.5
Hi Rob, it looks like this could help me, but uploading the file you provided for 2.5 isn’t working for me. I would like to try the modification you listed for the wait_timeout variable, but I can’t find that line in order to uncomment it. Which line number should it be on?
If you have time, maybe you can check out my problem and solutions I’ve tried.
Echoing LaurenMarie’s comment–couldn’t find the line either for the 2.5 flavored file.
Yes, it is missing from the 2.5 file. I will add it. In the meantime, you can look at one of the other versions as it is there in the other versions, and put it in the same place in the 2.5 version.
I wonder why if this works and default wordpress does not, why did they not adopt this into their original releases.
It’s been going on a long time now.
I just updated the 2.5 version so that the commented line that allows you to change the wait_timeout is now there.
Thanks so much, I was getting another error,
“Fatal error:Call to undefined method:wpdb->set_prefix()”
and this sorted it, much appreciated, Simon
my site database give problem any one know how to fix this plz help me site is http://www.znvj.com
Dude, you are a lifesaver! Thanks so much!
I’ve tested the 2.6 fix and it says it can’t connect to the database 😕
Sorry, the problem is that it can’t SELECT the database 😳
OK, I’ll see if I have some time to test 2.6 this weekend and see what the problem is.
Just FYI, I tested and had the same problem as Jose.
I found the problem with my untested version for 2.6 and I fixed it, tested it, and the 2.6 version on this site is now updated with the fix. Please let me know if you have a problem.
Hey Rob, I just got a message from a reader of my blog to say that I got a MySQL server has gone away error when he’d tried to comment on a post. I tried to reply and I got the same thing. Strange as everything had seemed to be working before this since I’d upgraded to 2.6. Anyway, I’ve employed your fix and everything seems to be OK now. Thanks a million, Rob. Rob!
[…] this WordPress defect, then I found that there are several possible causes to getting this error. Rob explains the error in his blog post. When someone tries to view one of your WordPress web pages, […]
thanks rob
[…] Workaround for WordPress database error: [MySQL server has gone away] for different versions of Word… […]
Thanks a lot. It worked for me wonderfully.
Hi Rob,
Anywhere I look for this error, I’m referred to your site. 🙂
The problem is I’ve tried your fix and:
1. With the normal wp-dbi I get an upgrade->server gone away loop
2. With your fix installed, I get a blank page
My front end isn’t working too.
Please, PLEASE help if you can.
Thanks,
Sid
Hello Rob,
An interesting this just happened. All that was happening in my previous message – just stopped happening, and my site is working again.
Thank you Sir!
Sid
It would be nice to have a this app for the new version 2.6.1!
Thanks!
For 2.6.1, there was no change in the wp-db.php file, so use the 2.6 version.
[…] Original complete article link with downloadable fixes for all WordPress versions […]
[…] (Esta versión es para WordPress 2.6 y WordPress 2.6.x, si queréis para versiones antiguas tenéis más aquí). La subiremos a wp-includes/wp-db.php (haciendo preferiblemente una copia de la existente), y […]
Great!!!!
Thanks a ton. applied the changes to wp-db.php file. thanks again…
It works for me.
Thanks alot.
Thanks. It worked for me.
You are a true hero. I have no idea why this worked but you fixed a big problem for me!
thx for the fix.
i freaked out when i saw the error.
made a quick google search.
found ur fix for the problem.
n everything turns out fine.
thx again
Thanks Rob,
Your workaround fixed my problem. You are The Greatest!!
the reason for “mysql server has gone away” in my case has been a too large sql query. while the content field for options in wordpress is defined as longtext (~2^32 bytes), the connection between php and the mysql server has a much smaller restriction: max_allowed_packet. in my case this was set to 1 mb (afaik, the default value). the option table entry is clearly above (~2mb). i figured this out after some debugging using your queryWithReconnect function. after setting max_allowed_packet to 16M in the [mysqld] section in my.ini, everything worked flawless.
bye,
tobias
[…] access the MySQL database but I’ll spare you the technical details (those interested can click here for the full details). Suffice to say that I felt a massive load of my mind when it finally worked […]
[…] Workaround for this MySQL problem has been best addressed in this article. […]
hey!, hello. i have WP 2.7 (Beta2) and i need this solution, but is not available. ¿will work the Workaround for WP 2.6 in WP 2.7? Thanks.-
[…] this doesn’t solve your problem, try the workaround by […]
[…] This WordPress database error appears on certain configurations and it manifests in very slow and no response, usually on your admin pages. Workaround for this MySQL problem has been best addressed in this article. […]
[…] This WordPress database error appears on certain configurations and it manifests in very slow and no response, usually on your admin pages. Workaround for this MySQL problem has been best addressed in this article. […]
[…] por lo general en su admin páginas. Workaround for this MySQL problem has been best addressed in this article . Para evitar este problema de MySQL ha sido la mejor forma de abordar en este […]
[…] This WordPress database error appears on certain configurations and it manifests in very slow and no response, usually on your admin pages. Workaround for this MySQL problem has been best addressed in this article. […]
Many thanks to you, Rob, for this excellent workaround.
Hi,
wordpress 2.7 is new, but this too has the bug? or already arranged?
[…] error MySQL server has gone away” -tyyppistä virhettä. Googlasin vähän ja löysin workaroundin, jota aionkin kokeilla heti kun saan muut ongelmat korjattua. Näiden jälkeen olisi vielä […]
I am out of the blue getting this MySQL error, but I tried installing this fix and it didn’t work. I’m running WP 2.7. Is the most recent fix compatible with 2.7?
The fix for WordPress 2.7 has been added to this page.
Hi people
As a fresh robsnotebook.com user i only want to say hi to everyone else who uses this bbs B-)
Thank you so much! it’s a great solvation of kind of panic.
It’s not clear in your “That Darn Caffeinated Content Update!” email if the title fix is in the fix on this page. I haven’t seen the “WordPress database error: [MySQL server has gone away]” error, so I’m hesitant to apply it.
Please advise, Kent
[…] It seems the problem is caused by heavy load from your hosting server. The workaround can be found here. If your “wait_timeout” variable is small, and your CPU is heavily loaded, it may make it more […]
Thank you so much. Your solution helped me resolve my problem, after WordPress was not showing any post, widgets, nada. Tech support of my hosting adviced me to reinstall wordpress (that meaned backup of important files, backup of database, I have a headache just thinking). The only problem now is that my blog still loads kinda slow. Would you recommend a plugin for cache?
GMZ and all:
This “workaround” that I have published is really just a band aid for the majority of problems. WordPress should not take so long to create a page, and if your wait_timeout is set high enough, you shouldn’t get this error message. Many people get this error because they have many plugins that do many mysql queries, slowing wordpress down. The real way to fix this problem is to find what is slowing your WordPress down so much – which can be a tedious process. One way to do this would be to disable 1 plugin at a time to see if it makes the problem go away.
I’ve been meaning to update the article for a while to say this.
[…] blah error. For all kinds of things. And when looking for the solution, I was reminded of this: Rob at Rob’s Notebook reworked the wp-db.php file to avoid such things. And surprisingly, searching for “WordPress database error MySQL server has gone away” took me a […]
thank man, your solution really help me alot, thank again
[…] One of my blog’s plugins was the source of many of the issues. That was an easy enough solution — I just deactivated and uninstalled it. The MySQL connection was lost. It’s a relatively simple fix for WordPress users, detailed right here. […]
The Workaround wp-db.php worked great for WP 2.7, but when I upgraded to WP 2.7.1 just days ago, it no longer worked. Now that I’ve rolled back to the original wp-db.php that came with 2.7.1 I’m getting the nasty old “MYSQL server has gone away” message again. Is anyone else having problems with the fix not working with 2.7.1 and is there a fix for the fix so that it WILL work in 2.7.1?
Thanks!
[…] ?? WordPress ????????????????????????????????????????????????? MySQL ?????????????????????? […]
I just wanted to say thank you for saving me time and my blog. The blog is new and I almost deleted/uninstalled the wordpress altogether and start all over again. But having written several post so far made me think again and I searched google for solution and luckily found your site.
Keep up the good work
Fatos
[…] ?? WordPress ????????????????????????????????????????????????? MySQL ?????????????????????? […]
[…] This WordPress database error appears on certain configurations and it manifests in very slow and no response, usually on your admin pages. Workaround for this MySQL problem has been best addressed in this article. […]
@WWW
I am about to have same problem, if I will use this script..
WWW: Can you download the 2.7.1 version to your computer (unzip it), and just replace the wp-db.php (from zip-file) file from there to your site?
Is there coming an update to this 2.7.1 version? I am too afraid to use this if my site ends up like Mr. http://WWW...
PS. GREAT, that someone has done these modifications actively! Thanks for that! 🙂
Hello Rob, could you help me?
Im having this error and my version is 2.1.3, do you know where to get the file?
I looked at 2.7.1, and it appears that there was no change in the official wp-db.php file. Therefore, the 2.7 workaround file should work in 2.7.1 also. I tested it and it works for me. I don’t know why WWW has a problem with it, but it worked for me.
@Sergio: I don’t have a workaround for version 2.1.3, but if you donate $30 to my site, I can create it for you.
Thank you sooo much! It worked for v2.7.1. 😀
You got a place at my favs. 😛
[…] Origional complete article link with downloadable fixes for all WordPress versions […]
[…] ?? WordPress ????????????????????????????????????????????????? MySQL ?????????????????????? […]
I’ve been running into this with WPMU ver 2.6.5. What would it take to impliment this fix for WPMU?
Thanks!
thx i will try this too after wp super cache .
[…] Workaround for this MySQL problem has been best addressed in this article. […]
This solution worked well for me. The SQL problem occured after switching to a php5 Server.
Solution: But the folloving line in the beginning of your .htaccess file
AddHandler php5-cgi .php
[…] If it contains “WordPress database error MySQL server has gone away for query” then click here and dont […]
[…] ?? WordPress ????????????????????????????????????????????????? MySQL ?????????????????????? […]
[…] ?? WordPress ????????????????????????????????????????????????? MySQL ?????????????????????? […]
Thanks, really useful. Saved me from the mess. I was thinking my database has gone corrupt.
Giving you a trackback from my blog!
Thanks alot. your solution worked for me 🙂
[…] This WordPress daTabase error appears on certain configurations and it manifests in very slow and no response, usually on your admin pages.?? WordPress ?????????????????????????????????????????????????MySQL ?????????????????????? […]
[…] This WordPress database error appears on certain configurations and it manifests in very slow and no response, usually on your admin pages. Workaround for this MySQL problem has been best addressed in this article. […]
Many thanks for this – am amazed that I can’t find significant discussion of the problem on the official WP support forums, but glad Google found you! I’m still having this problem in WP 2.8, by the way.
[…] it eventually got to me, and I found this site after a 2 second […]
Any idea if there needs to be a change in your updated file for the 2.8 upgrade? I’m getting this error message while attempting an upgrade from 2.7.1 to 2.8.
Is there any version that can be used in WP 2.8 ? THXS.
[…] [via] […]
2.8.1 workaround?
[…] MySQL ?????????????????????? […]
hello all
in need workaround for 2.8.1
that older workaround for example 2.7 work by new version 2.8.1
best regrds
Added the workarounds for versions 2.8 and 2.8.1.
Hey, thank rob…
you save a lot of me time, thank in advance 😛
greeting, hendra
Indonesia (there is no boom in here !!!, totally save)
[…] gibt es wie Sand am Meer, Google liefert Rund 18.900 Treffer. Es gibt Workarounds für die Datenbank-Klasse – aber diese »Blenden« das Problem letztendlich nur aus. Mag natürlich schön sein wenn nur […]
I just recently started getting these errors when refreshing my sitemaps in Google XML sitemaps plugin. I’m not sure what I did to fix it, but I just let it run through it’s course and it eventually made the errors go away and still rebuilt my sitemap.
[…] ?? WordPress ????????????????????????????????????????????????? MySQL ?????????????????????? […]
Thanks! it worked, but one thing that I struggled with was that, when I copied and pasted the text, I left some empty spaces at the end of the file, and this created some problems, thanks to http://www.hongkiat.com/blog/wordpress-error-warning-cannot-modify-header-information/comment-page-1/#comment-426679 I managed to fix it.
so.. if you get an ‘cannot modify header’ error after this fix, try to remove empty space in front of or at the end of this file.
[…] huge thank you to Rob at Rob’s Notebook for creating the fix to this issue, and getting my blog back up and running […]
Hi all, I got wordpress 2.8.4 and this same “WordPress database error: [MySQL server has gone away]” problem. Are you using the last fix (2.8) for this 2.8.4 version? Thx, lao
[…] https://robsnotebook.com/wordpress-mysql-gone-away Categories: Malo mešano Tags: Comments (0) Trackbacks (0) Leave a comment Trackback […]
[…] discuss that subject with us, Melissa Bradshaw implemented — at least for this blog — a workaround to change the MySQL wait_delay settings ourselves. Clever idea, and seemed to work for half a day — but now the problems have […]
Hi, I am getting this error ( my sql server gone away) all time.
I am using C api’s in my project.The connection is lost after 8 hours.( I have set hte wait_timeout to max which is 8 hours). How can i reconnect to the server? Thanks in advance
Is there a workaround for 2.8.4?
[…] This WordPress database error appears on certain configurations and it manifests in very slow and no response, usually on your admin pages. Workaround for this MySQL problem has been best addressed in this article. […]
[…] La Solución para este problema de MySQL se intenta abordar muy bien en este artículo. […]
[…] Rob of Rob’s notebook had the almost perfect solution for it. He created a replacement file for ‘wpdb.php’ which takes care of this problem, yeah it is temporary and you have to remember to replace this […]
[…] La Solución para este problema de MySQL se intenta abordar muy bien en este artículo. […]
,[…] robsnotebook.com is one must read source of tips on this subject,[…]
Thank you so much. The 2.8 fix works wonders for wordpress 2.9 as well. No more MySQL server has gone away errors for this little black duck. Yippee.
Hi,
Please, can you help me about this? I use wordpress MU and on my frontpage there is a forum which makes trouble. On every visit to this forum i got the error on error logs. This error like this:
WordPress database error for query: query_name
FROM xxxx_sfmembers
JOIN vzd_users ON xxx_users.ID = xxx_sfmembers.user_id
WHERE user_login = ‘admin’; made by sf_get_login_display_name
I think the problem on my user`s database. I need solve this problem as this is productive site.
Thank you.
[…] ?? WordPress ????????????????????????????????????????????????? MySQL ?????????????????????? […]
[…] timing out prematurely. You’ll see this on shared hosting services a lot of times. I found a great post on robsnotebooks.com that shows how to do this and even provides a way for WP to automatically reconnect to the database […]
hey i’m using wordpress 2.9. i am getting the my sql server has gone away error. please tell me wt all changes need to be done in wp-db.php file. reply please
And for 2.8.6 ?
Slow WordPress Blog Speedup Tips hyderabad…
Subscribe to this blog by mail or by RSS and get free stuff!Slow WordPress Blog Speedup TipsThe Unofficial AdSense Blog was a prime example of a slow WordPress blog, and it got to the point where I needed to fix things. So here are some things you ca…
[…] In case you’re having a WordPress blank page problem caused by ‘MySQL server has gone away’ – there is a solution that should work: https://robsnotebook.com/wordpress-mysql-gone-away […]
[…] results for this particular error message; this article seemed to be cited frequently in them: Workaround for WordPress database error: [MySQL server has gone away] for different versions of Word… __________________ ** Forum Re-Organization/Retired Forum Categories **User’s Guide : Answers […]
[…] they are monitoring something. 🙁 I googled around and there is some really old stuff on topic: https://robsnotebook.com/wordpress-mysql-gone-away http://wordpress.org/support/topic/110182 Had anyone encountered this? Is that core hack only […]
Hello,
Decent to be here.Good job buddy.
[…] Connection to MySQL server is shut down prematurely for any possible causes. Thanks to Rob for his Workaround for WordPress database error: [MySQL server has gone away]. The problem has been solved and now my WordPress works […]
[…] Workaround for WordPress database error: [MySQL server has gone away] for different versions of WordPress By daveamun Workaround for WordPress database error: [MySQL server has gone away] for different versions of Word…. […]
[…] as few websites already explained how to solve this problem. The first blog that I stumble upon is Robsnotebook, where he explained details on how to fix this […]
[…] timing out prematurely. You’ll see this on shared hosting services a lot of times. I found a great post on robsnotebooks.com that shows how to do this and even provides a way for WP to automatically reconnect to the database […]
Wonderful. Last time I re-installed it all. This time a wp-db refresh was all needed. Fantastic!
[…] This WordPress database error appears on certain configurations and it manifests in very slow and no response, usually on your admin pages. Workaround for this MySQL problem has been best addressed in this article. […]
[…] ?? WordPress ????????????????????????????????????????????????? MySQL ?????????????????????? […]
[…] timing out prematurely. You’ll see this on shared hosting services a lot of times. I found a great post on robsnotebooks.com that shows how to do this and even provides a way for WP to automatically reconnect to the database […]
My hosting provider is suspend my account due to many mysql connection. Please help me and how to resolve it. Thanks
Any chance you might make this into a WordPress plug-in so the base code doesn’t need to be modified?
Wow.. you detailed explain it…
Thanks for this great post 🙂
Hey, What about wordpress 3.0 😀
Can you *please* update this post to include WordPress 3.0?
I applied this workaround to WP 2.9.2 and it was working fine..
When I upgraded to WP3.0 the “WordPress database error MySQL server has gone away for query..” has returned, and this workaround no longer works..
[…] using Google, I eventually found this brilliant article at Rob’s Notebook called “Workaround for WordPress database error: [MySQL server has gone away] for different versions of Word…” that provides the workaround for this […]
would also love to get some information on this for WP 3.0.
[…] timing out prematurely. You’ll see this on shared hosting services a lot of times. I found a great post on robsnotebooks.com that shows how to do this and even provides a way for WP to automatically reconnect to the database […]
Excellent! Also your genius action was to include the original files with each workaround. By being able to do a diff between said files means one is able to see your changes and specifically how to build on this for a 3.01 workaround, thank you for this time saver 🙂
[…] La solution à ce problème a été abordée dans cet article. […]
[…] timing out prematurely. You’ll see this on shared hosting services a lot of times. I found a great post on robsnotebooks.com that shows how to do this and even provides a way for WP to automatically reconnect to the database […]
[…] is another article here that offers different solutions to this problem, although I could not find any solution for WP […]
Fixed. I was using v2.9.1 when i had the problem. Upgrading to 3.0.1 didn’t solve it. I uploaded the 2.8 workaround to it and its solved! Thanks! :p
[…] dans votre interface d’administration. La solution à ce problème a été abordée dans cet article. Évidement ce problème existe bien mais la solution suggérée ne fonctionnera que si vous mettez […]
For some hosting, installing wordpress has been their problem because of the errors they continuously receiving. I am glad that you pointed out different points here so wordpress users can easily determine what’s wrong with their installation.
I’ve got this problem with 3.1 and I couldn’t get the db.php to fix it, it just knocked all my blogs offline… 🙁
[…] reference: Workaround for WordPress database error How to fix “MySQL server has gone away” (error 2006) […]
[…] This WordPress database error appears on certain configurations and it manifests in very slow and no response, usually on your admin pages. Workaround for this MySQL problem has been best addressed in this article. […]
Rob –
Thanks for you help in this fix. Any idea on when we can expect a fix for WP 3.0+??
Thanks again for your help towards the community
Thanks for the fix Rob, I will be testing this against one of my websites, that was fine (or I didn’t notice this problem before) until 2 days ago.
I have no idea why now this website is showing the mysql gone away problem, I’ll uninstall every plug-in and keep testing.
It would definitely be nice to have a fix for WordPress 3.1, the wp-db.php file has changed a lot since this fix, and is difficult to make out what and where to change it.
If you found a solution for newer WP sites, please post it here.
Cheers,
Roderick.
Yes, 3.1 fix would come in handy 🙂
Hey,
just wanted you to know that I have found another reason for this behaviour to happen: Especialy on hosted websites you will find a rather small database-size. 100mb in my case for one database. When more data is written into the database than the hoster is providing you, wordpress might (or in my case will) show anywhere on the page those mysql-statements including errors of all kinds. The problem was semmelstatz. It gathered so much data that the table wp_statz alone had 160mb. I truncated the table and the problem was gone.
So, before you do anything critical or something that might take a lot of time: Check out your available database-size and weather your tables are going out of bounds…
Has anyone found a solution to this problem on WordPress 3.1?
I’ve got the solution on WordPress 3.1, just email me at wpmysql at(@)robsnotebook.com and I’ll tell you my fee.
Remember that this is a workaround. The real problem is that your mysql server is taking too long to respond. This workaround just makes your WordPress wait longer for the mysql server to respond. This workaround does not make your mysql server faster.
[…] Workaround for WordPress database error: [MySQL server has gone away] Relaterade inlägg :How do I import a MySQL dumpfile into my database?Optimizing MySQL – Queries and IndexesUsing PHP Objects to access your Database Tables (Part 1)mysql update from another tableMySQL :: Re: Problems in building 1.2.2 on Mac OS 10.5By Blogsdna […]
[…] I got it working in the end by applying this patch. […]
“The real problem is that your mysql server is taking too long to respond. This workaround just makes your WordPress wait longer for the mysql server to respond. This workaround does not make your mysql server faster.”
So if mysql is taking too long, we should apply the workaround only long enough to get the database backed up then get mysql fixed. Since Google is using page load times as a ranking factor, this issue could give a site’s ranking a demerit.
Thanks for the info and I think I’ll look at the server and my db backups first.
Hello ROB,
I was hoping you can also help me out with this error :
Internal server 500 Error
Do we have any workaround for this ? And what is the reason behind this error ?
I have same problem with WP 3.1.1. My mysql is fast, much ram, optimized settings. I only have this in WP and currently only with one plugin which parses feeds. I don’t know how to solve it.
I found my solution, I just raised like described above wait_timeout and also interactive_timeout.
[…] This WordPress database error appears on certain configurations and it manifests in very slow and no response, usually on your admin pages. Workaround for this MySQL problem has been best addressed in this article. […]
[…] depois de debugar descobrir que havia alguma coisa errada no SQL, então eu descobrir neste link como resolver esse problema que é recorrente desde as versões antigas do WP, mas é lógico como […]
[…] La Solución para este problema de MySQL se intenta abordar muy bien en este artículo. […]
[…] La Solución para este problema de MySQL se intenta abordar muy bien en este artículo. […]