Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #2889 (closed defect: invalid)

Opened 4 years ago

Last modified 3 years ago

lost db connectivity after updating rails

Reported by: "monkievox" <colman@rominato.com> Assigned to: Jeremy Kemper <rails@bitsweat.net>
Priority: high Milestone: 1.0
Component: ActiveRecord Version: 0.14.3
Severity: major Keywords: mysql
Cc:

Description

My rails project was working (for the most part). I updated rails, restarted everything, and now when I fire up my rails app (without changing any code), I suddenly get an InvalidStatement error: "Lost connection to MySQL server during query: SELECT * FROM man_departments WHERE (man_departments.id = 3) LIMIT 1"

So, I tinkered with the "database.yml" settings and this is what I discovered:

I AM UNABLE to make my rails app work with the exact same settings which I had before, when my rails app was working fine.

I AM ABLE to make my rails app work if I change the "username"/"password" to "root"/"" (on my dev machine there is a MySQL user named "root" with no password). For some strange reason it won't take the previously working username/password.

I have made no changes to my MySQL user accounts.

My working database.yml ...

development:
  adapter:  'mysql'
  database: 'rominato_development'
  socket:   'localhost'
  username: 'root'
  password: ''

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
  adapter:  'mysql'
  database: 'rominato_test'
  socket:   'localhost'
  username: 'root'
  password: ''

production:
  adapter:  'mysql'
  database: 'rominato_production'
  socket:   'localhost'
  username: 'root'
  password: ''

My previously working, but now non-working database.yml ...

development:
  adapter:  'mysql'
  database: 'rominato_development'
  socket:   'localhost'
  username: 'rominato'
  password: '********'

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
  adapter:  'mysql'
  database: 'rominato_test'
  socket:   'localhost'
  username: 'rominato'
  password: '********'

production:
  adapter:  'mysql'
  database: 'rominato_production'
  socket:   'localhost'
  username: 'rominato'
  password: '********'

My OS is ... Microsoft Windows XP [Version 5.1.2600]

My MySQL version is ... 5.0.15

My Ruby version is ...

C:\>ruby -v

ruby 1.8.2 (2004-12-25) [i386-mswin32]

My Gems are ...

*** LOCAL GEMS ***

actionmailer (1.1.3, 1.1.2)
    Service layer for easy email delivery and testing.

actionpack (1.11.0, 1.10.2)
    Web-flow and rendering framework putting the VC in MVC.

actionwebservice (0.9.3, 0.9.2)
    Web service support for Action Pack.

activerecord (1.13.0, 1.12.2)
    Implements the ActiveRecord pattern for ORM.

activesupport (1.2.3, 1.2.2)
    Support and utility classes used by the Rails framework.

fxri (0.3.2)
    Graphical interface to the RI documentation, with search engine.

fxruby (1.2.6)
    FXRuby is the Ruby binding to the FOX GUI toolkit.

postgres-pr (0.4.0)
    A pure Ruby interface to the PostgreSQL (>= 7.4) database

rails (0.14.3, 0.14.2)
    Web-application framework with template engine, control-flow layer,
    and ORM.

rake (0.6.2)
    Ruby based make-like utility.

sources (0.0.1)
    This package provides download sources for remote gem installation

Change History

11/16/05 05:03:48 changed by bitsweat

  • keywords set to fd mysql.
  • owner changed from David to bitsweat.
  • severity changed from normal to critical.
  • milestone set to 1.0.

You upgraded from 0.13.1 to 0.14.3? Or from 0.14.3 to svn trunk? Or ?

11/16/05 19:01:05 changed by "monkievox" <colman@rominato.com>

Oops, I thought I included that info. I upgraded from 0.14.2 to 0.14.3

11/16/05 19:09:12 changed by "monkievox" <colman@rominato.com>

To be more specific, I executed the following on the command line:

>gem install rails --remote

My understanding is this is an appropriate way to keep current with the latest stable rails release.

11/19/05 07:46:38 changed by bitsweat

  • keywords changed from fd mysql to mysql.
  • priority changed from normal to high.
  • severity changed from critical to major.

monkievox, in 0.14.3 the MySQL driver included with Rails was updated.

The existing ruby-mysql driver does not support the new client protocol and password hashing style introduced in MySQL 4.1. So a Rails user created a "shim" which added support to the driver, but unfortunately disabled old-style password hashing as a result.

Recently, someone else patched the ruby-mysql driver to support these new features and did so in a more compatible way, so we adopted the patch rather than continue to use the shim.

But it appears the updated driver is not handling password hashing correctly for you. Do other database operations execute as expected?

I hope we can get this resolved with the ruby-mysql driver, but in the meantime I highly recommend you use the native C driver instead. It's confusingly named mysql-ruby. It's available as a RubyGem, but it requires a C compiler so you're probably out of luck on Windows. You can get it from the rubyforapache project instead: select mysql.so in the .exe installer.

http://rubyforge.org/projects/rubyforapache

11/19/05 07:49:58 changed by bitsweat

Also, thank you for providing such a good report of the error and the steps you took to resolve it.

11/19/05 09:10:59 changed by "monkievox" <colman@rominato.com>

Other database operations seem to execute as expected (with the exception of another problem I am reporting in ticket #2888, which may not be ruby-mysql related).

Thank you for the link to "ruby for apache". I will continue to develop with the "root/no password" workaround. Hopefully when I am ready for the deployment of my application (I have already secured a Rails-friendly account with TextDrive) I can revisit this issue and find the mysql driver working properly.

Thank you so much for your help so far :)

06/04/06 00:03:09 changed by mislav@nippur.irb.hr

  • status changed from new to closed.
  • resolution set to invalid.

Closed. This is mysql/driver related - if you set up everything on the server correctly it is clear that it works.