Reputation: 3638
For my Heroku app (Rails 3.1.4 and Ruby 1.9.2), I'm trying to change to a database that is using MySQL2, but I'm receiving an error from Heroku (which is crashing my app):
3.1.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `rescue in establish_connection': Please install the mysql12 adapter: `gem install activerecord-mysql12-adapter` (no such file to load -- active_record/connection_adapters/mysql12_adapter) (RuntimeError) EXCEPT
In my gemfile, I have:
group :production do
gem "mysql2", "~> 0.3.11"
end
group :development, :test do
gem 'mysql', '2.8.1'
end
In my database.yml, I have:
development:
adapter: mysql
production:
adapter: mysql2
Here's what I've tried unsuccessfully(all attempts installed correctly locally and in Heroku):
Per this answer, I tried (in my gemfile), mysql2 version "< 0.3"
Per another answer for that question, I tried '< 0.3.7' which didn't work
I tried gem "mysql2", "~> 0.3.11" per this answer, but it didn't work
Per the gem's site, I tried (in my gemfile), mysql2 version "~> 0.2.7" and it installed mysql2 0.2.18 (successfully locally and in Heroku)
Upvotes: 5
Views: 2680
Reputation: 416
I'm sure you've figured this out or moved on long ago, but I was running into the same issue and thought I'd share what worked for me for anyone else who comes along.
In addition to what you mention above, if you're using Heroku you also have to specify mysql2:// in the DATABASE_URL instead of mysql://. See the ClearDB writeup here: https://devcenter.heroku.com/articles/cleardb
And update their instructions to use mysql2:// instead of mysql:// like so:
heroku config:add DATABASE_URL='mysql2://adffdadf2341:[email protected]/heroku_db?reconnect=true'
Hope that helps.
Upvotes: 30