1

我只是遇到一个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

4

1 回答 1

0

您应该查看这个链接,它很好地概述了如何在 Mountain Lion 上设置 MySQL。正如 OP 所提到的,主要方法是依赖brew install而不是 dmg 文件。

于 2012-08-26T05:16:01.443 回答