0

我刚刚开始在 Rails 上运行 ruby​​,我仍在忙于设置一切运行.. 我遇到的问题是它一直说 mysql2 不是捆绑包的一部分.. 我已经用谷歌搜索了它,但解决方案没有似乎工作

sudo gem install mysql2 

ETC..

我得到的东西是

$ rake db:create rake 中止!请安装 mysql2 适配器:gem install activerecord-mysql2-adapter(mysql2 不是捆绑包的一部分。将其添加到 Gemfile。) /Library/Ruby/Gems/1.8/gems/bundler-1.3.2/lib/bundler/rubygems_integration.rb:214:ingem' /Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/connection_adapters/mysql2_adapter.rb:3 /Library/Ruby/Gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in要求' /Library/Ruby/Gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in require' /Library/Ruby/Gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:inload_dependency' /Library/Ruby/Gems/1.8/gems/activesupport-3.2.12/lib/ active_support/dependencies.rb:251:in require' /Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:inresolve_hash_connection' /Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_specification.rb:29:inestablish_connection spec' /Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in'/Library/Ruby/ Gems/1.8/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:90:increate_database' /Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:62 /Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:62:in每个'/Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:62 任务:TOP => db:create(通过使用 --trace 运行任务查看完整跟踪)

这里有人知道我的解决方案吗?( ps 我看到很多人说它必须添加到 gem 配置中,但是如何?)

4

1 回答 1

1

您应该确保您的Gemfile(位于项目的根目录中)包括

gem 'mysql2'

然后运行bundle install安装它。

我相信activerecord-mysql2-adaptergem 是作为依赖项安装的,但您也可以添加

gem 'activerecord-mysql2-adapter'

如果它仍然要求它。

于 2013-03-07T23:49:52.493 回答