Home >Database >Mysql Tutorial >Ruby使用MySQL问题记录

Ruby使用MySQL问题记录

WBOY
WBOYOriginal
2016-06-07 17:19:26856browse

使用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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn