Search code examples
ruby-1.9.2ruby-on-rails-2mysql2compatibility

how to set up mysql2 with rails2


I've upgraded my app to Rails 2.3.14 and Ruby 1.9.2, and I've been having all sorts of strange issues with MySQL. At first, I've used the ruby-mysql gem (2.9.3), until I realized it had some encoding problems, and the consensus seems to be to upgrade to using mysql2 gem.

So, I've removed the old ruby-mysql adapter and installed mysql2, and also included it in my application's Gemfile:

gem 'mysql2', '< 0.3'

In addition, I've updated database.yml with adapter: mysql2. From what I've read on the documentation this should be it, but I keep getting a crash when trying to boot my app:

$ ./script/server
=> Booting WEBrick
=> Rails 2.3.14 application starting on http://0.0.0.0:3000
vendor/rails/activesupport/lib/active_support/dependencies.rb:182:in `require': no such file to load -- mysql (MissingSourceFile)
from ..vendor/rails/activesupport/lib/active_support/dependencies.rb:182:in `block in require'
from ..vendor/rails/activesupport/lib/active_support/dependencies.rb:547:in `new_constants_in'
from ..vendor/rails/activesupport/lib/active_support/dependencies.rb:182:in `require'
from ..config/environment.rb:81:in `<top (required)>'
...

I thought this should be a drop in replacement for mysql adapter in Rails. Anything I need to configure differently?


Solution

  • It looks like you forgot to remove the original mysql gem from your Gemfile.