Skip to main content
 首页 » 编程设计

ruby-on-rails之mysql2 gem 安装正常,但在运行 "Please install the myslq2 adapter..."时仍然得到 "rake db:migrate"

2025年05月04日110unruledboy

我已经在这里阅读了大量关于 mysql2 的帖子,但是尽管 gem 似乎安装得很好,但在运行任何 rake db 任务或 rails 命令时仍然会出错。在我的 Gemfile 中:

source 'http://rubygems.org' 
 
gem 'rails', '3.0.7' 
gem 'mysql2' 

在我的远程服务器上,我运行了以下命令:
$ bundle install 
... 
Using mysql2 (0.2.7) 
... 
Using rails (3.0.7) 
... 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. 
 
$ rake db:schema:load 
(in ...) 
rake aborted! 
Please install the myslq2 adapter: `gem install activerecord-myslq2-adapter` (no such file to load -- active_record/connection_adapters/myslq2_adapter) 
 
$ gem install activerecord-myslq2-adapter 
ERROR:  Could not find a valid gem 'activerecord-myslq2-adapter' (>= 0) in any repository 
 
$ gem install mysql2 
Building native extensions.  This could take a while... 
Successfully installed mysql2-0.3.2 
1 gem installed 
Installing ri documentation for mysql2-0.3.2... 
Enclosing class/module 'mMysql2' for class Result not known 
Installing RDoc documentation for mysql2-0.3.2... 
Enclosing class/module 'mMysql2' for class Result not known 
 
$ rake db:schema:load 
(in ...) 
rake aborted! 
Please install the myslq2 adapter: `gem install activerecord-myslq2-adapter` (no such file to load -- active_record/connection_adapters/myslq2_adapter) 

还有什么我想念的吗?谢谢你。

请您参考如下方法:

这很尴尬,但对于可能遇到同样问题的其他人来说:

确保您的 database.yml 文件具有所有正确的拼写并且没有转置的 Ls 或 Qs:

# Correct 
development: 
  adapter: mysql2 

并不是:
# Incorrect 
development: 
  adapter: myslq2 

请注意,我的 OP 上的最后一行提示丢失了 myslq2 适配器。也许有人可以创建一个名为 myslq2 的项目的克隆,以防万一:)