我通过macport安装了ruby和ruby gems,但是gem列表不包括mysql2。那么我如何将 mysql2 gem 安装在“/opt/local/bin/gem”内的 gem 列表中
另外,mysql2 gem 是什么?我有 mysql gem,只想使用 mysql,不太确定 mysql2 意味着什么。当我尝试在应用程序上启动 webrick 时,它给出了 mysql2 错误。
更新: 我运行 sudo gem install mysql2 并得到以下结果:
Building native extensions. This could take a while... Successfully installed mysql2-0.2.7 1 gem installed Installing ri documentation for mysql2-0.2.7...
Enclosing class/module 'mMysql2' for class Client not known
Enclosing class/module 'mMysql2' for class Result not known Installing RDoc documentation for mysql2-0.2.7...
Enclosing class/module 'mMysql2' for class Client not known
Enclosing class/module 'mMysql2' for class Result not known
假设安装了 mysql2,即使文档没有,当我尝试在我的应用程序中启动 webrick 时,我收到以下错误。
rails 服务器:
/opt/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: dlopen(/opt/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /opt/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle Reason: image not found - /opt/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle from /opt/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8 from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:inrequire' from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in
require' from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:ineach' from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:in
require' from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:ineach' from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:in
require' from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler.rb:112:inrequire' from /Users/summer/Sites/simple_cms/config/application.rb:7 from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in
require' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28 from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:intap' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27 from script/rails:6:in
require' from script/rails:6
最佳答案
据我所知,两个 gem(mysql 和 mysql2)之间的区别之一是 mysql2 在 UTF-8 下工作得更好。这里is an article关于它。
要安装 mysql2 gem,只需运行:
gem install 'mysql2'
关于ruby-on-rails - 安装 mysql2 gem 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5773698/