Mysql::Error: Lost connection to MySQL server during query

I have been very VERY frustrated for the past week trying to solve a
seemingly spurious problem with my Windows XP SP2 box with Ruby
1.8.2/Rails 1.0.0/MySQL 5.0.16 or 4.1.15 (yes, I tried both) installed
running against a remote MySQL server that was either 3.23 or 4.1
(4.1.15 to be exact–we finally matched them both up to make sure that
wasn’t the problem).

So I post it here (as well as in the Rails_Engine forum, where it first
arose for me), in the hopes that it will save someone else some
significant trouble.

Just for the record, in case others have this problem, what I did was
download a compresssed .RAR file for mysql 4.1.15 (mysql-ruby-win32.rar)
and copied the mysql.so file to the location specified in the readme at
this link:

http://jeroen.concept-q.biz/files/

This did the trick… I’ve spent more than 3 days pulling my hair out
(as well as my business partner who’s also lost some hair as well–plus
he hates it when I pull his hair ;-), but didn’t discover this link
until just now. Thanks Colin!! (original source:
http://weblog.rubyonrails.com/articles/2005/10/30/get-10-15-more-performance-with-mysql-rails
thread # 29. Which, unfortunately, I can’t post to, in order to help
others who may have this same problem.)

EVERYONE: If you are getting ANY kind of MySQL::Error, in particular
what I was getting was variations of this:

Mysql::Error: Lost connection to MySQL server during query [ . . . ]

(Buried deep in a stack trace from Rails–this wasn’t occuring for a
local instance of MySQL server, but only when it was running on a remote
server–in our case on a 1&1 dedicated–I think Fedora–host that we
self-manage. Of course the adapter worked fine from the server itself
AND it worked fine from a Mac OS X box running the identical
Ruby/Rails/login_engine code against this remote MySQL server, but
always got the error above when running from my Windows XP SP 2 box.)

Anyway, if you have this problem, try going to the above URL and
download the .RAR file there (you may need to download WinACE or
something similar to read .rar compressed files), then read the
readme.txt located within and copy the file where it directs.

Good luck!

~ Brad

There is a bug with WEBrick that will cause MySQL errors to be
displayed.

The ticket contains the problem, and the fix:
http://dev.rubyonrails.org/ticket/3433

Since this bug is timing related, changing drivers, running on a
different
platform, or running MySQL over the net could also cause it to appear or
disappear.

If you’re not running WEBrick, you won’t see the problem in the ticket.