# Lost Connection to MySql during query

**URL:** <https://www.ruby-forum.com/t/lost-connection-to-mysql-during-query/56716>\
**Category:** Rails\
**Created:** [April 3, 2006, 9:19am UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-during-query/56716 "2006-04-03T09:19:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Lewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/fbc32d/32.png) [@Ben\_Lewis](https://www.ruby-forum.com/u/Ben_Lewis)\
**Post date:** [April 3, 2006, 9:19am UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-during-query/56716/1 "2006-04-03T09:19:16Z")

</div>

hi all,

I am getting an error when trying to connect to a mysql server on my  
‘production’ linux server. The rails app works fine when connecting to  
the ‘development’ mysql on my windows development server.

I have looked at the following wiki:  
[http://wiki.rubyonrails.com/rails/pages/Mysql+Connection+Problems/](http://wiki.rubyonrails.com/rails/pages/Mysql+Connection+Problems/)  
and I installed the mysql gem, however this does not seem to have fixed  
the problem.

The exact error message is as follows  
Mysql::Error: Lost connection to MySQL server during query: SELECT  
COUNT(\*) FROM Orders

The following is my list of installed gems on the production linux  
server.

#gem list  
\*\*\* LOCAL GEMS \*\*\*  
actionmailer (1.2.0, 1.1.5)  
actionpack (1.12.0, 1.11.2)  
actionwebservice (1.1.0, 1.0.0)  
activerecord (1.14.0, 1.13.2)  
activesupport (1.3.0, 1.2.5)  
fcgi (0.8.6.1)  
mysql (2.7)  
rails (1.1.0, 1.0.0)  
rake (0.7.0)  
sources (0.0.1)

The production server is running FC4.

I can connect to the production mysql server using the username and  
password supplied in the rails app.

Don’t know if its relevant, but the webserver is running lighttpd.

Any Ideas?

Thanks,  
~Ben

---

<div class="post-metadata">

**Author:** ![Ben\_Lewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/fbc32d/32.png) [@Ben\_Lewis](https://www.ruby-forum.com/u/Ben_Lewis)\
**Post date:** [April 3, 2006, 9:44am UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-during-query/56716/2 "2006-04-03T09:44:29Z")

</div>

On Mon, 2006-04-03 at 09:19 +0200, Ben Lewis wrote:

> actionpack (1.12.0, 1.11.2)
> 
> I can connect to the production mysql server using the username and  
> password supplied in the rails app.
> 
> Don’t know if its relevant, but the webserver is running lighttpd.
> 
> Any Ideas?

* * *

1 - did you install mysql gem on the fedora system?

sudo gem install mysql

2 - did you fix for shift from Windows to Linux?

cd /rails\_root  
rake rails:update

3 - SELinux issues?

look for errors in /var/log/messages - things about ‘avc denied’

4 - it’s only relevant about webserver and lighttpd if it’s not working.

look for errors in /rails\_root/log/production.log  
look for errors in /var/log/lighttpd/error\_log

Craig

---

<div class="post-metadata">

**Author:** ![Ben\_Lewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/fbc32d/32.png) [@Ben\_Lewis](https://www.ruby-forum.com/u/Ben_Lewis)\
**Post date:** [April 4, 2006, 4:13am UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-during-query/56716/3 "2006-04-04T04:13:06Z")

</div>

Copying mysql.so into \1.8\i386-mswin32\ solved “Lost connection to  
MySQL  
server” when connecting to remote server from XP.  
[http://wiki.rubyonrails.com/rails/pages/HowToUseMySQLRubyBindingsOnWin32](http://wiki.rubyonrails.com/rails/pages/HowToUseMySQLRubyBindingsOnWin32)

---

<div class="post-metadata">

**Author:** ![Ben\_Lewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/fbc32d/32.png) [@Ben\_Lewis](https://www.ruby-forum.com/u/Ben_Lewis)\
**Post date:** [April 4, 2006, 12:31am UTC](https://www.ruby-forum.com/t/lost-connection-to-mysql-during-query/56716/4 "2006-04-04T00:31:54Z")

</div>

> 1 - did you install mysql gem on the fedora system?
> 
> sudo gem install mysql  
> Yes

> 2 - did you fix for shift from Windows to Linux?
> 
> cd /rails\_root  
> rake rails:update  
> I don’t know what this achieves, but I get the following errors several  
> hundred times.  
> /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active\_support/inflections.rb:2:  
> warning: ambiguous first argument; put parentheses or even spaces

> 3 - SELinux issues?
> 
> look for errors in /var/log/messages - things about ‘avc denied’  
> SELinux not enabled. No Errors in this log file.

> 4 - it’s only relevant about webserver and lighttpd if it’s not working.  
> Note - I only get this error using the production mysql server. The  
> development mysql server works fine.
> 
> look for errors in /rails\_root/log/production.log  
> No Errors

> look for errors in /var/log/lighttpd/error\_log  
> No Errors
