Ruby on rails connection problem

I have a Ruby on Rails project that I was developing on a hosted server but have decided to work on my local windows machine with.

To get started I thought I’d make sure that I could just take my models from the old project and put them in a new project then query them in the console. This fails.

Edit to reflect more accurate problem:
The connection that rails builds to query my models can run only one query then gives the “Not connected” exception for all subsequent queries. Anybody know what’s going on? I’ve checked my configuration, a lot. If there’s some setting on mysql server that I don’t know about I’d be willing to look at that.

Stack Trace:

ActiveRecord::StatementInvalid: Mysql::Error: query: not connected: SHOW FIELDS FROM `prices`
        from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log'
        from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/mysql_adapter.rb:320:in `execute'
        from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/mysql_adapter.rb:466:in `columns'
        from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1271:in `columns'
        from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1279:in `columns_hash'
        from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1578:in `find_one'
        from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1569:in `find_from_ids'
        from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:616:in `find'
        from (irb):2

I’ve verified that my MySQL database is accepting connections and has the data and structure I expect. I’ve double checked my connections, etc. Can anyone shed some light?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I found a solution to this problem in an aptana forum.

There it says that the MySQL 5.1 client library doesn’t play well with Rails 2.2
The solution they offer is simple: download an older MySQL client library (libmySQL.dll) and copy it to your Rubybin folder.

This worked for me (Windows XP, Ruby 1.8.6, Rails 2.3.3, mysql 5.1.33)

Method 2

Check that you have the latest mysql gem (for rails > 2.1.2)

Verify your config/database.yml file (adapter, passwords). Check that it is set correctly for all the environments (dev, prod test)

Verify that your mysql is running

Method 3

download an older MySQL client library

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x