我通过macport安装了ruby和ruby gems,但是gem列表中不包含mysql2。那么我该如何把mysql2 gem安装到我的gem列表中呢?这个列表位于"/opt/local/bin/gem"
还有,mysql2的gem是什么?我有mysql gem,只想使用mysql,不确定mysql2是什么意思。当我尝试在应用程序上启动webrick时,它会给我一个mysql2错误。
更新:我运行sudo gem install mysql2,得到如下结果:
构建本地扩展。这可能需要一段时间……成功已安装mysql2-0.2.7 1 gem安装ri文档mysql2-0.2.7…
封装类/模块'mMysql2class Client not known
封装类/模块'mMysql2类结果未知安装RDoc
mysql2-0.2.7…封装类/模块'mMysql2class Client not known
封装类/模块'mMysql2class Result not known
假设安装了mysql2,即使文档没有,当我尝试在我的应用程序中启动webrick时,我得到以下错误:
rails服务器:/opt/地方/lib/ruby/珠宝/1.8/珠宝/mysql2-0.2.7/lib/mysql2/mysql2.bundle:dlopen (/opt/地方/lib/ruby/珠宝/1.8/珠宝/mysql2-0.2.7/lib/mysql2/mysql2.bundle,9):库未加载;libmysqlclient.18。dylib (LoadError)
引用:/opt/地方/lib/ruby/珠宝/1.8/珠宝/mysql2-0.2.7/lib/mysql2/mysql2.bundle原因:没有找到图像/opt/地方/lib/ruby/珠宝/1.8/珠宝/mysql2-0.2.7/lib/mysql2/mysql2.bundle从/opt/地方/lib/ruby/珠宝/1.8/珠宝/mysql2-0.2.7/lib/mysql2.rb: 8从/opt/地方/lib/ruby/珠宝/1.8/珠宝/bundler-1.0.7/lib/打包机/runtime.rb: 64:在require' from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in
要求从/opt/地方/lib/ruby/珠宝/1.8/珠宝/bundler-1.0.7/lib/打包机/runtime.rb: 62:在each' from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:in
要求从/opt/地方/lib/ruby/珠宝/1.8/珠宝/bundler-1.0.7/lib/打包机/runtime.rb: 51:each' from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:in
要求从/opt/地方/lib/ruby/珠宝/1.8/珠宝/bundler-1.0.7/lib/bundler.rb: 112:在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/地方/lib/ruby/珠宝/1.8/珠宝/railties-3.0.7/lib/铁路/commands.rb: 28从/opt/地方/lib/ruby/珠宝/1.8/珠宝/railties-3.0.7/lib/铁路/commands.rb: 27日:tap' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27 from script/rails:6:in
要求"从脚本/rails: 6
据我所知,两个gem (mysql和mysql2)之间的区别之一是mysql2在UTF-8下工作得更好。这里有一篇关于它的文章。
安装mysql2 gem,只需运行:
gem install 'mysql2'
要搜索可用的远程gems,请运行此命令Gem search mysql -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)mysql (0.2.7, 0.2.6 x86-mingw32 x86-mswin32-60)mysql2_bigint (0.2.6.1)mysql2_model (0.1.2)mysql2mysql(发布)mysql2psql (0.1.0)mysql2xxxx (0.0.4)
从gem列表中选择mysql2并运行Sudo gem install mysql