【问题标题】:Unable ro run "rake db:schema:dump" and getting an error无法运行“rake db:schema:dump”并出现错误
【发布时间】:2015-03-04 10:44:36
【问题描述】:

我正在尝试启动数据库并仍在学习 ruby​​ on rails。但在这一步中,我在cmd 中运行以下代码时出现错误。

我已经安装了mysql2,它出现在 gem 列表中。我将教程示例文件中的database.yml 文件放到我的工作文件夹中。仍然得到错误。并再次安装所有mysql2。再次安装包。

注意:我使用的是 Windows 8.1 64 位。

C:\Users\Thilanka\myapp>rake db:schema:dump
DL is deprecated, please use Fiddle
rake aborted!
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not load
ed. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum
 required by ActiveRecord).

Gem::LoadError: mysql2 is not part of the bundle. Add it to Gemfile.

Tasks: TOP => db:schema:dump => db:load_config
(See full trace by running task with --trace)

【问题讨论】:

    标签: ruby-on-rails ruby database mysql2


    【解决方案1】:

    请确保您的Gemfile 中有以下行:

    gem 'mysql2'
    

    将该行添加到Gemfile 后,运行bundle install。

    如果您仍有问题,可能需要阅读install notes for Windows。

    【讨论】:

      【解决方案2】:

      我不确定 Windows 在这种情况下的行为如何,但根据我的经验(仍在学习 RoR,我正处于 sqlite 和 mysql 之间的迁移过程中)。 我做的第一件事是在我的电脑上安装 mysql,然后正如@spickermann 所说,在 Gemfile 中声明 gem 并运行 bundle install。

      对于您显示的错误 (Gem::LoadError: mysql2 is not part of the bundle. Add it to Gemfile.),您似乎错过了 Gemfile 步骤。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-08-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-02
        相关资源
        最近更新 更多