首页 > 数据库 > mysql教程 > Ruby使用MySQL问题记录

Ruby使用MySQL问题记录

WBOY
发布: 2016-06-07 17:19:26
原创
857 人浏览过

使用gem安装mysql2的时候提示以下错误extconf.rb:2:in `require

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

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

解决办法:在Gemfile里面把mysql2的版本调低一点设成gem 'mysql2', '

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

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

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

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

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安装成功。

linux

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板