安装mysql2 gem

时间:2014-06-30 19:52:40

标签: mysql sql ruby-on-rails ruby gem

我已经尝试安装mysql 2 gem来开始构建我的rails应用程序。我有Rails 4.0.4和Ruby 1.9.3p545。在工作了好几天之后,我一直遇到同样的错误。我再次尝试安装mysql 32位版本,以确保我有正确的版本与正确的连接器,将我的libmysql.dll和libmysql.lib移动到我的ruby / bin文件夹,并尝试了其他几种方法,使我的工作,我在网上找到。他们都没有为我工作。以下就是我所拥有的。我很感激任何帮助我最终安装mysql2 gem。

PS C:\Users\pc> gem install mysql2 --no-rdoc --no-ri -- '--with-mysql-lib="C:\Program Files\MySQL\
.6\lib\" --with-mysql-include="C:\Program Files\MySQL\MySQL Server 5.6\include\"'
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-lib=C:\Program Files\MySQL\MySQL Server 5.6\lib" --with-mys
Program Files\MySQL\MySQL Server 5.6\include"'
This could take a while...
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

    C:/Ruby193/bin/ruby.exe extconf.rb --with-mysql-lib=C:\Program Files\MySQL\MySQL Server 5.6\lib" --wit
e=C:\Program Files\MySQL\MySQL Server 5.6\include"
checking for ruby/thread.h... no
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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:/Ruby193/bin/ruby
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib=${mysql-dir}/lib
        --with-mysql-config
        --without-mysql-config
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib=${mysql-dir}/lib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-mlib
        --without-mlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-zlib
        --without-zlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-socketlib
        --without-socketlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-nsllib
        --without-nsllib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-mygcclib
        --without-mygcclib
        --with-mysqlclientlib
        --without-mysqlclientlib

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.16 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/extensions/x86-mingw32/1.9.1/mysql2-0.3.16/gem_make.out 

1 个答案:

答案 0 :(得分:2)

我们编写了一个关于如何执行此操作的教程here

-

您正在做的事情有几个问题:

  
      
  1. 路径中不能有任何空格
  2.   
  3. 您需要包含最新版本的MYSQL C-Connector
  4.   

这对我们有用:

  
      
  • 下载MYSQL C-Connector
  • 的最新 32位版本   
  • 安装到路径不含空格
  •   
  • 使用以下命令:

         

    gem install mysql2 --platform=ruby -- ‘--with-mysql-dir=”C:\mysql-connector-path”’

  •   

这应该正确安装