RuntimeError with mysql2 and rails3 (bundler)

I get this error

`establish_connection': Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (no such file to load -- active_record/connection_adapters/mysql2_adapter) (RuntimeError) from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activerecord- 

Here the dump of the whole error and my config and gemfile.

+76
mysql ruby-on-rails bundler
Aug 12 '10 at 11:20
source share
11 answers

I had the same error after upgrading from Ubuntu from 11.10 to 12.04. Here is how I fixed the problem:

 gem uninstall mysql2 bundle 

I think the key here is the "native extensions" - I believe that when I installed the latter, I used a different version of mysql.

 Installing mysql2 (0.3.11) with native extensions 
0
Aug 19 '12 at 17:58
source share

I was getting the same error when using rails 3.0.7 and mysql2 0.3.2. The solution I found here is to use an older version of mysql2. So edit your gemfile in

 gem 'mysql2', '< 0.3' 

and run

 bundle install 
+101
May 18 '11 at 17:27
source share

You also need to change the adapter from mysql to mysql2 in database.yml, as said here Install the mysql2 gem on Snow Leopard for Rails 3 with rvm

From:

development: adapter: mysql

To:

development: adapter: mysql2

+36
Nov 28 '10 at 19:47
source share

Did you include the mysql2 gem file in your gemfile instead of the old mysql gem and subsequently installed the package?

+14
Aug 12 '10 at 11:23
source share

If you are using rvm and may have added mysql2 outside of rvm, do the following: Confirm that your Gemfile says:

 gem 'mysql2' 

or for Rails2.x:

 gem 'mysql2', '~> 0.2.11' 

then

 $ cd RAILS_ROOT $ gem uninstall mysql2 Select gem to uninstall: 1. mysql2-0.2.11 2. mysql2-0.3.6 3. All versions > 3 # select "All versions" $ rvm gemset install mysql2 $ bundle install 

Now the rails should start properly.

+6
Oct 29 '11 at 20:05
source share

This also fixed the issue I ran into:

 Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (no such file to load -- active_record/connection_adapters/mysql2_adapter) 

You really need to run: gem install mysql2 and add the gem to your configuration.

+3
Oct 26 '10 at 20:00
source share

just run "gem install mysql" also add the same to gemfile and run the package. worked

+2
Jan 15 '11 at 11:16
source share

If someone is still having the problem of setting the mysql2 buffer with rails 3 on Windows, refer to the detailed installation instructions -

http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html

+2
May 03 '11 at 2:55
source share

I am new to ruby, rails and Linux. Therefore, if this solution does not work, I am not responsible :)

Step 1:

 sudo gem uninstall mysql2 

Step 2:

 sudo gem install mysql -v 0.2.7 

Run webrick, if the same problem still appears, reinstall the rails.

This solution works for me.

+1
Jun 03 2018-11-11T00:
source share

Same problem for me too. Updated to Rails 3.1.rc4, and then downgraded to 3.0.3. Worked for me.

+1
Jun 30 '11 at 0:00 a.m.
source share

from 0.3.0 and ActiveRecord 3.1 - the ActiveRecord adapter was pulled out of this gem by itself in ActiveRecord. If you need to use mysql2 with Rails versions <3.1 make sure and specify the gemstone "mysql2", "~> 0.2.7" in your Gemfile

the missing file ( no such file to load ) can be found in mysql2 versions up to version 0.3.0.

given in mysql2 documentation

0
Aug 01 2018-12-12T00:
source share



All Articles