简体   繁体   English

安装mysql2 gem错误

[英]installing mysql2 gem errors

I installed ruby and ruby gems through macport but the gem list does not include mysql2. 我通过macport安装了ruby和ruby gems,但是gem列表不包含mysql2。 So how would I get mysql2 gem installed inside my gem list which is inside "/opt/local/bin/gem" 那么我如何在“ / opt / local / bin / gem”里面的gem列表中安装mysql2 gem?

Also, what is the mysql2 gem? 另外,什么是mysql2 gem? I have mysql gem and only want to use mysql, not really sure what it means by mysql2. 我有mysql gem,只想使用mysql,不太确定mysql2是什么意思。 It gives my a mysql2 error when I try to launch webrick on an app. 当我尝试在应用程序上启动webrick时,它给我一个mysql2错误。

UPDATE: I ran sudo gem install mysql2 and got the following: 更新:我运行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... 这可能需要一段时间...成功安装了mysql2-0.2.7 1个gem已安装正在安装mysql2-0.2.7的ri文档...

Enclosing class/module 'mMysql2' for class Client not known 封闭类Client的类/模块'mMysql2'

Enclosing class/module 'mMysql2' for class Result not known Installing RDoc documentation for mysql2-0.2.7... 封闭类Result的类/模块'mMysql2'未知为mysql2-0.2.7安装RDoc文档...

Enclosing class/module 'mMysql2' for class Client not known 封闭类Client的类/模块'mMysql2'

Enclosing class/module 'mMysql2' for class Result not known 封闭类Result的类/模块'mMysql2'

Assuming that mysql2 installed, even though the docs didn't I get the following error when I try to launch webrick in my app. 假设安装了mysql2,即使我没有尝试在我的应用中启动webrick时,文档也没有出现以下错误。

rails server: 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) /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):库未加载: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:in require' 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:in each' 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:in each' 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:in require' 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 引用自:/opt/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle原因:找不到映像-/opt/local/lib/ruby/gems/1.8/ /opt/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8来自/ opt / local /中的gems / mysql2-0.2.7 / lib / mysql2 / mysql2.bundle 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:64:in require'来自/opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62 each' 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: each' from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:in要求中'来自/opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler.rb:112:in require' 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 /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:in tap' 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 require' 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'来自/opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28来自/ opt / local / lib / ruby / gems / 1.8 / gems / railties-3.0.7 / lib / rails / commands.rb:27:in tap' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27 from script/rails:6:in script / rails:6

In order to perform a search for remote gems that are available run the command gem search mysql2 -r (note the -r at the end) 为了对可用的远程gem执行搜索,请运行命令gem search mysql2 -r(注意末尾的-r)

* REMOTE GEMS * *远程宝石*

activerecord-mysql2legacydb-adapter (0.2.0) activerecord-mysql2spatial-adapter (0.3.2) em_mysql2_connection_pool (0.0.5) ghazel-mysql2 (0.2.6.3) mysql2 (0.2.7, 0.2.6 x86-mingw32 x86-mswin32-60) mysql2_bigint (0.2.6.1) mysql2_model (0.1.2) mysql2mysql (0.0.2) mysql2psql (0.1.0) mysql2xxxx (0.0.4) activerecord-mysql2legacydb-adapter(0.2.0)activerecord-mysql2spatial-adapter(0.3.2)em_mysql2_connection_pool(0.0.5)ghazel-mysql2(0.2.6.3)mysql2(0.2.7,0.2.6 x86-mingw32 x86-mswin32- 60)mysql2_bigint(0.2.6.1)mysql2_model(0.1.2)mysql2mysql(0.0.2)mysql2psql(0.1.0)mysql2xxxx(0.0.4)

from the list of gems you should pick mysql2 and run sudo gem install mysql2 从gem列表中,您应该选择mysql2并运行sudo gem install mysql2

As far as I know, one of the differences between the two gems (mysql and mysql2) is that mysql2 works better with UTF-8. 据我所知,两个gem(mysql和mysql2)之间的区别之一是mysql2与UTF-8更好地兼容。 Here is an article about it. 是一篇关于它的文章

To install your mysql2 gem, just run: 要安装mysql2 gem,只需运行:

gem install 'mysql2'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM