Missing gemstone mysql2. Add it to your Gemfile: gem 'mysql2'

Version

  • ruby 1.9.2-p290
  • rails 3.0.9
  • mysql2-0.2.13 under rvm
  • ubuntu 11.04

gem is installed with "gem install mysql2 -v '<0.3'". All dependencies were fulfilled.

rails and c rails are working fine.

I need to run a script outside the rails environment using activerecord 3.0.9. When I run the script, this is the output:

========================

/home/ross/work/x/library/models.rb:27:in `eval': !!! Missing the mysql2 gem. Add it to your Gemfile: gem 'mysql2' (RuntimeError) from /home/ross/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/mysql_adapter.rb:19:in `mysql_connection' from /home/ross/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `new_connection' .... 

=========================

It’s clear that there is stone, because the rails work.

I don’t know why the stone was not found when running the script?

Can anyone shed some light on the problem?

Relations Ross

+6
source share
2 answers

In case this helps someone, in my case I forgot to change the adapter in database.yml to mysql2 for the production database, the Gemfile was fine (upgrade from rails from 2.3.4 to 3.0. 9).

+22
source

Check database.yml first

You have something like this:

 development: adapter: mysql encoding: utf8 ... 

To solve your problem you need to replace mysql with mysql2 .

Correct version of database.yml

 development: adapter: mysql2 encoding: utf8 ... 
+15
source

Source: https://habr.com/ru/post/896814/


All Articles