# Troubleshooting "Lost connection to MySQL server.."

**URL:** <https://www.ruby-forum.com/t/troubleshooting-lost-connection-to-mysql-server/62582>\
**Category:** Rails\
**Created:** [June 6, 2006, 9:28am UTC](https://www.ruby-forum.com/t/troubleshooting-lost-connection-to-mysql-server/62582 "2006-06-06T09:28:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 6, 2006, 9:28am UTC](https://www.ruby-forum.com/t/troubleshooting-lost-connection-to-mysql-server/62582/1 "2006-06-06T09:28:24Z")

</div>

Hello all,

Though I’ve read all I could about the “Lost connection to MySQL  
server during query: SHOW FIELDS FROM …”, I’m still unable to use RoR.

I’m on Linux Mandriva 2006 / MySQL-4.1.12 / ruby-1.8.2

- The userid/password have access to the database and the table (it’s  
the root user on MySQL)

- I’m on a nonstandard socket/port, but I’ve set the socket in  
config/databases.yml

- The table exists, the name is all lowercase and plural (“recipes”)

- The table has a primary key called ‘id’ (int, autoincrement)

- I don’t have the “old passwords” in my MySQL setup

- The Application Trace, Framework Trace, Full Trace, session dump  
don’t show anything useful

- The MySQL log shows nothing either. Nor syslog.

How on earth can I find out exactly what is going on ?  
Is there some place where RoR dumps exactly what it is trying to do  
and what error status it receives ?

Thanks for any help  
– Jean Marc

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 6, 2006, 2:37pm UTC](https://www.ruby-forum.com/t/troubleshooting-lost-connection-to-mysql-server/62582/2 "2006-06-06T14:37:34Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Hello all,
> 
> Though I’ve read all I could about the “Lost connection to MySQL  
> server during query: SHOW FIELDS FROM …”, I’m still unable to use RoR.

I seem to remember I got this until I installed the mysql gem.

A.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 6, 2006, 2:38pm UTC](https://www.ruby-forum.com/t/troubleshooting-lost-connection-to-mysql-server/62582/3 "2006-06-06T14:38:53Z")

</div>

Alan F. wrote:

> removed\_email\_address@domain.invalid wrote:
> 
> > Hello all,
> > 
> > Though I’ve read all I could about the “Lost connection to MySQL  
> > server during query: SHOW FIELDS FROM …”, I’m still unable to use RoR.
> 
> I seem to remember I got this until I installed the mysql gem.
> 
> A.

[http://wiki.rubyonrails.org/rails/pages/Mysql+Connection+Problems](http://wiki.rubyonrails.org/rails/pages/Mysql+Connection+Problems)

Ignore all the apt-get stuff and scroll until you see the gem 🙂

A.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 7, 2006, 12:23pm UTC](https://www.ruby-forum.com/t/troubleshooting-lost-connection-to-mysql-server/62582/4 "2006-06-07T12:23:59Z")

</div>

I know this question is about Linux - but for the benefit of others  
searching for this problem…

I had this on windows until I installed the newest mysql/ruby bindings  
available here:

[http://www.vandomburg.net/pages/mysql-ruby-windows](http://www.vandomburg.net/pages/mysql-ruby-windows)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 6, 2006, 3:58pm UTC](https://www.ruby-forum.com/t/troubleshooting-lost-connection-to-mysql-server/62582/5 "2006-06-06T15:58:24Z")

</div>

> > > Though I’ve read all I could about the “Lost connection to MySQL  
> > > server during query: SHOW FIELDS FROM …”, I’m still unable to use RoR.

Thanks to all (thanks Alan) :

- On Mandriva 2006 with MySQL : install the following packages :

ruby  
apache-mod\_ruby  
ruby-RubyGems  
ruby-mysql

Then install the Rails gem with dependencies.  
gem install --remote rails

To check : gem list --local

I have those on my machine :  
actionmailer (1.2.1)  
actionpack (1.12.1)  
actionwebservice (1.1.2)  
activerecord (1.14.2)  
activesupport (1.3.1)  
rails (1.1.2)  
rake (0.7.1)  
sources (0.0.1)

I guess that the mysql gem which does not appear here is in fact set  
up by the ruby-mysql package, at least on Mandriva. It works, whereas  
“gem install mysql – --with-mysql-config=`which mysql_config`”  
seems to require the Ruby headers and asks what version of ruby-mysql  
you want.

Setup the config/database.yml, not forgetting to set,  
if necessary, the path to a non-standard socket :

development:  
adapter: mysql  
database: mydatabase  
username: myuser  
password: mypassword  
host: localhost  
socket: /path/to/nonstandard.sock

Make sure that your MySQL database does not use the “old password”  
system (see in my.cnf and check with mysql\_fix\_privilege\_tables)

Create a table with the proper name (for example “recipes” all  
lowercase, plural if you follow  
[Radar – O’Reilly](http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html))

Make sure that this table has a primary key called “id” (all  
lowercase, integer, auto increment, primary)

Make sure that your user can access the database and the table

Then try  
ruby script/generate scaffold Recipe  
If you don’t get any error message, it looks good.

Then  
ruby script/server

and browse to [http://localhost:3000/recipe](http://localhost:3000/recipe)

Should Work First Time ™ :-)))

– Jean Marc
