未初始化的常量Mysql2 :: Client :: REMEMBER_OPTIONS

时间:2012-08-26 05:12:21

标签: ruby-on-rails mysql2 nameerror

我只遇到一个uninitialized constant错误,我现在不知道。请保存我的一天。

我正在尝试使用mongodb&同时mysql2 .Mongodb还行。现在我想在我的项目中添加mysql2 gem。

gem install mysql2 -- --srcdir=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config并将mysql2添加到Gemfile

当我重新启动服务器时,它会给我这个错误:

/usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:12:in `<class:Client>': uninitialized constant Mysql2::Client::REMEMBER_OPTIONS (NameError)
    from /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:2:in `<module:Mysql2>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:1:in `<top (required)>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/lib/mysql2.rb:10:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/lib/mysql2.rb:10:in `<top (required)>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `each'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `block in require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `each'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler.rb:120:in `require'
    from /Users/Liber/ktv/trunk/config/application.rb:11:in `<top (required)>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in <top (required)>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
    from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

我该如何解决这个问题?谢谢。

 <class:Client>': uninitialized constant Mysql2::Client::REMEMBER_OPTIONS (NameError)

---------------------------解------------------- ---------

只需

brew install mysql
  

请勿使用DMG文件安装mysql

然后:

sudo gem install mysql2 --with-mysql-config=/usr/local/mysql/bin/mysql_config

现在一切都好。

谢谢@BenjaminTan

1 个答案:

答案 0 :(得分:0)

您应该查看此链接,其中列出了nicely how to setup MySQL on Mountain Lion。主要的内容是依赖于brew install而不是dmg文件,正如OP所提到的那样。