# Lost connection to MySQL server during query

**URL:** <https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query/48986>\
**Category:** Rails\
**Created:** [November 28, 2005, 6:09am UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query/48986 "2005-11-28T06:09:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![johanatan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johanatan](https://www.ruby-forum.com/u/johanatan)\
**Post date:** [November 28, 2005, 6:09am UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query/48986/1 "2005-11-28T06:09:30Z")

</div>

hello,

I just upgraded to latest version of Rails in an attempt to get rid of  
the SessionRestore issue discussed here:  
[Peak Obsession](http://wiki.rubyonrails.com/rails/pages/HowtoAvoidSessionRestoreError).  
At the bottom of the page, it says this problem has been fixed in the  
newest version of rails. However, after installing, I am now getting  
the error mentioned in the subject although the actual SQL statement it  
is complaining about works fine from other mysql clients. Does anyone  
have a clue about what is going on?

Thanks in advance,  
Jonathan

---

<div class="post-metadata">

**Author:** ![johanatan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johanatan](https://www.ruby-forum.com/u/johanatan)\
**Post date:** [November 28, 2005, 9:36am UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query/48986/2 "2005-11-28T09:36:45Z")

</div>

Jonathan Leonard wrote:

> I just upgraded to latest version of Rails in an attempt to get rid of  
> the SessionRestore issue discussed here:  
> [Peak Obsession](http://wiki.rubyonrails.com/rails/pages/HowtoAvoidSessionRestoreError).  
> At the bottom of the page, it says this problem has been fixed in the  
> newest version of rails. However, after installing, I am now getting  
> the error mentioned in the subject although the actual SQL statement it  
> is complaining about works fine from other mysql clients. Does anyone  
> have a clue about what is going on?

I’ve spent much of today finding a fix for this. See:  
[Peak Obsession](http://wiki.rubyonrails.com/rails/pages/Mysql+Connection+Problems/)

Installing the mysql gem fixed it for me. (If the install fails,  
see [http://www.ocsforums.com/showthread.php?t=132](http://www.ocsforums.com/showthread.php?t=132) )

–  
We develop, watch us RoR, in numbers too big to ignore.

---

<div class="post-metadata">

**Author:** ![johanatan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johanatan](https://www.ruby-forum.com/u/johanatan)\
**Post date:** [November 28, 2005, 5:46pm UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query/48986/3 "2005-11-28T17:46:37Z")

</div>

mrj wrote:

> I’ve spent much of today finding a fix for this. See:  
> [Peak Obsession](http://wiki.rubyonrails.com/rails/pages/Mysql+Connection+Problems/)
> 
> Installing the mysql gem fixed it for me. (If the install fails,  
> see [http://www.ocsforums.com/showthread.php?t=132](http://www.ocsforums.com/showthread.php?t=132) )
> 
> –  
> We develop, watch us RoR, in numbers too big to ignore.

I’m working on Windows at the moment. So, I’m pretty sure it isn’t the  
Fedora gcc compiler. 🙂 Here’s the result of trying to install the  
mysql gem:

C:\Documents and Settings\Jonathan\>“c:\ruby\bin\ruby.exe”  
“c:\ruby\bin\gem” inst  
all mysql  
Attempting local installation of ‘mysql’  
Local gem file not found: mysql\*.gem  
Attempting remote installation of ‘mysql’  
Updating Gem source index for: [http://gems.rubyforge.org](http://gems.rubyforge.org)  
Building native extensions. This could take a while…  
ERROR: While executing gem … (RuntimeError)  
ERROR: Failed to build gem native extension.  
Gem files will remain installed in  
c:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7 for  
inspection.  
ruby extconf.rb install mysql\nchecking for mysql\_query() in  
mysqlclient.lib…  
. no  
checking for main() in m.lib… yes  
checking for mysql\_query() in mysqlclient.lib… no  
checking for main() in z.lib… no  
checking for mysql\_query() in mysqlclient.lib… no  
checking for main() in socket.lib… no  
checking for mysql\_query() in mysqlclient.lib… no  
checking for main() in nsl.lib… no  
checking for mysql\_query() in mysqlclient.lib… no

Results logged to c:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7/gem\_make.out

Is it because I didn’t point it to ‘mysql\_config’? If so, where is this  
file on Windows and how do I point it to it.

Thanks.

---

<div class="post-metadata">

**Author:** ![johanatan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johanatan](https://www.ruby-forum.com/u/johanatan)\
**Post date:** [November 28, 2005, 8:29pm UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query/48986/4 "2005-11-28T20:29:10Z")

</div>

Under Windows installing native msql binding from gem does not work.  
Looking to your log seems that Makefile did not generated. You should  
fix  
extconf.rb first (and also do not forget to install MSVC, better .Net  
2003).

But easier for you would be download compiled \*.so file. You could find  
it  
here [http://pomozov.info/opensource.php#mysql\_ruby](http://pomozov.info/opensource.php#mysql_ruby) (ver 2.7, by [VS.Net](http://VS.Net))

---

<div class="post-metadata">

**Author:** ![johanatan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johanatan](https://www.ruby-forum.com/u/johanatan)\
**Post date:** [November 28, 2005, 10:05pm UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query/48986/5 "2005-11-28T22:05:34Z")

</div>

anatol.pomozov wrote:

> Under Windows installing native msql binding from gem does not work.  
> Looking to your log seems that Makefile did not generated. You should  
> fix  
> extconf.rb first (and also do not forget to install MSVC, better .Net  
> 2003).
> 
> But easier for you would be download compiled \*.so file. You could find  
> it  
> here [http://pomozov.info/opensource.php#mysql\_ruby](http://pomozov.info/opensource.php#mysql_ruby) (ver 2.7, by [VS.Net](http://VS.Net))

Thanks for the answer. That fixed this problem. However, there is  
still a problem with logging in. I hit the ‘login’ button and nothing  
ever happens.

Here is an excerpt from the log file:

Processing SecurityController#login (for 127.0.0.1 at 2005-11-28  
15:55:44) [POST]  
Parameters: {“user\_login”=\>“blaird”, “action”=\>“login”,  
“controller”=\>“security”, “user\_password”=\>“test123”, “login”=\>“Login  
\302\273”}  
e[4;36;1mUser Load (0.000000)e[0m e[0;1mSELECT \* FROM users WHERE  
(login = ‘blaird’ AND password =  
‘5544dcd960516e6465fbd5b28bccbc2d5a3498e3’ AND active = ‘Yes’) LIMIT  
1e[0m  
Redirected to [http://127.0.0.1:3000/main](http://127.0.0.1:3000/main)  
e[4;35;1mUser Columns (0.031000)e[0m e[0mSHOW FIELDS FROM userse[0m  
Completed in 0.04700 (21 reqs/sec) | DB: 0.03100 (65%) | 302 Found  
[[http://127.0.0.1/security/login](http://127.0.0.1/security/login)]

It looks as if the login succeeds and a redirect to /main is attempted,  
but that never manifests in the browser.

Any ideas?

(One other thing, the server seems generally more unstable now. Even  
after closing the webrick server and restarting it and closing and  
restarting the browser, the home page is not being shown (which was  
working even though the login failed)).

---

<div class="post-metadata">

**Author:** ![johanatan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johanatan](https://www.ruby-forum.com/u/johanatan)\
**Post date:** [November 29, 2005, 7:29pm UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-server-during-query/48986/6 "2005-11-29T19:29:49Z")

</div>

> Thanks for the answer. That fixed this problem. However, there is  
> still a problem with logging in. I hit the ‘login’ button and nothing  
> ever happens.
> 
> Here is an excerpt from the log file:
> 
> Processing SecurityController#login (for 127.0.0.1 at 2005-11-28  
> 15:55:44) [POST]  
> Parameters: {“user\_login”=\>“blaird”, “action”=\>“login”,  
> “controller”=\>“security”, “user\_password”=\>“test123”, “login”=\>“Login  
> \302\273”}  
> e[4;36;1mUser Load (0.000000)e[0m e[0;1mSELECT \* FROM users WHERE  
> (login = ‘blaird’ AND password =  
> ‘5544dcd960516e6465fbd5b28bccbc2d5a3498e3’ AND active = ‘Yes’) LIMIT  
> 1e[0m  
> Redirected to [http://127.0.0.1:3000/main](http://127.0.0.1:3000/main)  
> e[4;35;1mUser Columns (0.031000)e[0m e[0mSHOW FIELDS FROM userse[0m  
> Completed in 0.04700 (21 reqs/sec) | DB: 0.03100 (65%) | 302 Found  
> [[http://127.0.0.1/security/login](http://127.0.0.1/security/login)]
> 
> It looks as if the login succeeds and a redirect to /main is attempted,  
> but that never manifests in the browser.
> 
> Any ideas?
> 
> (One other thing, the server seems generally more unstable now. Even  
> after closing the webrick server and restarting it and closing and  
> restarting the browser, the home page is not being shown (which was  
> working even though the login failed)).

Anyone else having similar problems after upgrading rails? Is there a  
way to revert back to an old installation of rails? Gem always gets the  
latest version, no?
