使用windows安装mysql2时出错

时间:2011-11-23 12:57:34

标签: mysql ruby devkit

我可以使用以下命令安装mysql2,这很奇怪: $ gem install mysql2 --platform=ruby -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"'以下是结果:

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.10
1 gem installed
Installing ri documentation for mysql2-0.3.10...
Installing RDoc documentation for mysql2-0.3.10...

但是当我正在运行bundle install时(显然我需要安装很多宝石),它无法安装mysql2,所以bundle install停在那里,这真让我疯狂。谁有人可以帮忙?多谢了! 以下是bundle install的结果:

Installing mysql2 (0.3.8) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
.

        c:/Ruby192/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... no
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=c:/Ruby192/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


Gem files will remain installed in G:/Desktop/20090319-/Rails Examples/ClockingI
T/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.8 for inspection.
Results logged to G:/Desktop/20090319-/Rails Examples/ClockingIT/vendor/bundle/r
uby/1.9.1/gems/mysql2-0.3.8/ext/mysql2/gem_make.out
An error occured while installing mysql2 (0.3.8), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.8'` succeeds before bundling.

4 个答案:

答案 0 :(得分:8)

在我的ubuntu机器上,必须首先运行apt-get install libmysqld-dev,然后运行gem install mysql2 ...它就像魅力一样:)

答案 1 :(得分:2)

尝试从bundle外部安装mysql,如果可以的话,从Gemfile中删除mysql

 sudo gem install mysql --no-rdoc --no-ri -- 

- 与MySQL的-配置=的/ usr /本地/ MySQL的/斌/ mysql_config

另外

apt-get install libmysqld-dev

答案 2 :(得分:0)

您尝试安装的mysql2 gem版本在Windows上存在问题。

请安装mysql2 gem而不指明版本:

gem install mysql2

答案 3 :(得分:0)

罚款,请下载mysql-connector-c-6.1.5-win32版本,解压缩该文件夹,然后试试。

适合我。

gem install mysql2 --no-ri --no-rdoc --platform = ruby​​ - --with-mysql-include = C:\ mysql-connector \ mysql-connector-c-6.1.5-win32 \ include --with-mysql-lib = C:\ mysql-connector \ mysql-connector-c-6.1.5-win32 \ lib