ruby2.1.3无法连接mysql
win8.1x64zh_cn,ruby2.1.3x64wininstaller安装,devkit已安装DevKit-mingw64-64-4.7.2-20130224-1...
win8.1 x64 zh_cn ,ruby 2.1.3 x64 win installer安装,devkit已安装 DevKit-mingw64-64-4.7.2-20130224-1432-sfx
问题来了:
require mysql找不到,于是安装mysql的dbi,gem install mysql,报错信息如下,请问怎么破?谢谢!
D:\Ruby21-x64\devkit>gem install mysql
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
d:/Ruby21-x64/bin/ruby.exe extconf.rb
checking for main() in -llibmysql... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=d:/Ruby21-x64/bin/ruby
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-libmysqllib
--without-libmysqllib
extconf failed, exit code 1
Gem files will remain installed in d:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/mysql-
2.9.1 for inspection.
Results logged to d:/Ruby21-x64/lib/ruby/gems/2.1.0/extensions/x64-mingw32/2.1.0
/mysql-2.9.1/gem_make.out
d:/Ruby21-x64/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': 126: 找不到指定的模块。 - d:/Ruby21-x64/lib/ruby/gems/2.1.0/extensions/x64-mingw32/2.1.0/mysql-2.9.1/mysql/mysql_api.so (LoadError)
程序很简单,就是require “mysql”看看能不能成功。 展开
问题来了:
require mysql找不到,于是安装mysql的dbi,gem install mysql,报错信息如下,请问怎么破?谢谢!
D:\Ruby21-x64\devkit>gem install mysql
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
d:/Ruby21-x64/bin/ruby.exe extconf.rb
checking for main() in -llibmysql... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=d:/Ruby21-x64/bin/ruby
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-libmysqllib
--without-libmysqllib
extconf failed, exit code 1
Gem files will remain installed in d:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/mysql-
2.9.1 for inspection.
Results logged to d:/Ruby21-x64/lib/ruby/gems/2.1.0/extensions/x64-mingw32/2.1.0
/mysql-2.9.1/gem_make.out
d:/Ruby21-x64/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': 126: 找不到指定的模块。 - d:/Ruby21-x64/lib/ruby/gems/2.1.0/extensions/x64-mingw32/2.1.0/mysql-2.9.1/mysql/mysql_api.so (LoadError)
程序很简单,就是require “mysql”看看能不能成功。 展开
1个回答
展开全部
ruby在windows下使用mysql要注意
要装mysql2
要指定mysql-connector的目录,注意你的目录可能跟我的不一样
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector\"'
我当时用的是ruby2.1.1,不过应该差别不大
追问
非常感谢你的回答,我提问后google了一下,尝试了几种方法,你说的这个确实解决问题了,mysql的gem安装成功,但是执行程序仍会报错,如下,请问是啥问题?
见原提问,谢谢!
追答
require 'mysql2'啊。现在不都用mysql2吗, rails new xxxx --database=mysql默认都用mysql2
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询