Ruby使用MySQL问题记录_Ruby_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > Ruby > Ruby使用MySQL问题记录

Ruby使用MySQL问题记录

 2012/8/21 11:11:11  zhanger  程序员俱乐部  我要评论(0)
  • 摘要:1.使用gem安装mysql2的时候提示以下错误extconf.rb:2:in`require':nosuchfiletoload--mkmf(LoadError)fromextconf.rb:2Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingmysql2:ERROR:Failedtobuildgemnativeextension./usr/bin/ruby1.8extconf.rbextconf.rb:2
  • 标签:使用 Ruby 问题 SQL MySQL

?

1.使用gem安装mysql2的时候提示以下错误extconf.rb:2:in `require': no such file to load -- mkmf (LoadError) from extconf.rb:2

Building native extensions.? This could take a while...
ERROR:? Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:2:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:2

原因:缺少mkmf,mkmf.rb is part of the ruby1.8-dev package。

解决办法:sudo apt-get install ruby1.8-dev

?

2.WARNING: This version of mysql2 (0.3.2) doesn't ship with the ActiveRecord adapter bundled anymore as it's now part of Rails 3.1
WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x

原因:rails版本小于3.1,mysql2版本大于0.3,造成版本不兼容;

解决办法:在Gemfile里面把mysql2的版本调低一点设成gem 'mysql2', '< 0.3'就可以了,或者直接gem install mysql2 -v 0.2.7安装一个确切的版本,再在gemfile中将mysql2设成该版本;或者把rails升级到3.1以上版本,该方法未验证。


3.Installing mysql2 (0.3.6) D:/develop/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/defaults/operating_system.rb:9:in `block in <t

op (required)>': The 'mysql2' native gem requires installed build tools. (Gem::InstallError)

原因:缺少devkit,无法安装mysql2;

解决办法:去'http://rubyinstaller.org/downloads?下载devkit,然后按照http://github.com/oneclick/rubyinstaller/wiki/Development-Kit?的说明安装测试,再执行即可。


4.安装mysql2时报ERROR:Failed?to?build?gem?native?extension.,具体如下:

Building?native?extensions.??This?could?take?a?while...

ERROR:??Error?installing?mysql2:

ERROR:?Failed?to?build?gem?native?extension.

google后发现很多人在安装的时候把mysql自身的参数带上就可以装成功,比如带--with-mysql-lib=${mysqlLibPath}或--with-mysql-dir=${mysqlDir}或--with-mysql-config=${mysqlConfigPath}。都有试过还是一样,最后从apt中装了个mysql的开发包libmysqlclient-dev,才从gem上将mysql安装成功。

?

发表评论
用户名: 匿名