[英]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 is dump of whole error and my config and gemfile. 这是整个错误和我的配置和gemfile的转储。
Also need to change adapter from mysql
to mysql2
in database.yml as said here Install mysql2 gem on Snow Leopard for Rails 3 with rvm 还需要在database.yml中将mysql
适配器从mysql
更改为mysql2
,如上所述在rails中安装带有Rails 3的Snow Leopard上的mysql2 gem
From: 从:
development: adapter: mysql
To: 至:
development: adapter: mysql2
您是否在gemfile中包含mysql2 gem而不是旧的mysql gem,然后运行bundle install?
If you're using rvm, and possibly added mysql2 outside of rvm, try these steps: Confirm that your Gemfile says: 如果您正在使用rvm,并且可能在rvm之外添加了mysql2,请尝试以下步骤:确认您的Gemfile说:
gem 'mysql2'
or for Rails2.x: 或者对于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 rails should start properly. 现在rails应该正常启动。
This also fixed the issue I had with: 这也解决了我遇到的问题:
Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (no such file to load -- active_record/connection_adapters/mysql2_adapter)
You actually need to run: gem install mysql2 and add the gem to your config. 你实际上需要运行:gem install mysql2并将gem添加到你的配置中。
just run "gem install mysql" also add the same in gemfile and run bundle. 只需运行“gem install mysql”也可以在gemfile中添加相同的内容并运行bundle。 worked 工作
If anybody still facing problem of installing mysql2 gem with rails 3 on Windows, then refer to the detailed steps of installation on - 如果有人仍然面临在Windows上使用rails 3安装mysql2 gem的问题,请参阅安装的详细步骤 -
http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html
I'm a beginner at ruby, rails, and linux. 我是ruby,rails和linux的初学者。 So if this solution did not work, I hold no responsibility :) 所以,如果这个解决方案不起作用,我不承担任何责任:)
Step 1: 步骤1:
sudo gem uninstall mysql2
Step 2: 第2步:
sudo gem install mysql -v 0.2.7
Start webrick, if the same problem still appears reinstall rails. 启动webrick,如果同样的问题仍然出现重新安装rails。
This solution works for me. 这个解决方案适合我。
Same issue for me too. 对我来说同样的问题。 Upgraded to Rails 3.1.rc4 then downgraded to 3.0.3. 升级到Rails 3.1.rc4然后降级到3.0.3。 Worked for me. 为我工作。
as of 0.3.0, and ActiveRecord 3.1 - the ActiveRecord adapter has been pulled out of this gem and into ActiveRecord itself. 从0.3.0开始,ActiveRecord 3.1 - ActiveRecord适配器已从这个gem中拉出并进入ActiveRecord本身。 If you need to use mysql2 with Rails versions < 3.1 make sure and specify gem "mysql2", "~> 0.2.7" in your Gemfile 如果你需要使用带有Rails版本<3.1的mysql2,请确保在你的Gemfile中指定gem“mysql2”,“〜> 0.2.7”
the missing file ( no such file to load
) can be found in the pre 0.3.0 versions of mysql2. 缺少的文件( no such file to load
)可以在pre.03.0版本的mysql2中找到。
quoted from the documentation of mysql2 引自mysql2的文档
I had the same error after upgrading from Ubuntu 11.10 to 12.04. 从Ubuntu 11.10升级到12.04后,我遇到了同样的错误。 This is how I fixed the problem: 这就是我解决问题的方法:
gem uninstall mysql2
bundle
I think the key here is the 'native extensions' -- I suppose when I installed last, I was using a different version of mysql. 我认为这里的关键是'原生扩展' - 我想当我上次安装时,我使用的是不同版本的mysql。
Installing mysql2 (0.3.11) with native extensions
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.