Ruby:安装mysql2

时间:2013-11-30 18:05:44

标签: ruby windows mysql2

Windows 7 32位

大家好,如何在Windows 7中正确安装mysql2我有这个错误:

    c:\dev\mysql2>gem install mysql2-0.3.13.gem --no-ri --no-rdoc -- --with-mysql-di r=c:\mysql-connector-c-noinstall-6.0.2-win32

This could take a while...
ERROR:  Error installing mysql2-0.3.13.gem:
        ERROR: Failed to build gem native extension.

    C:/Ruby200/bin/ruby.exe extconf.rb --with-mysql-dir=c:\mysql-connector-c-noi
nstall-6.0.2-win32

Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.
3.13 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.13/ext/mysql2/g
em_make.out

C:\ dev的\ mysql2>

1 个答案:

答案 0 :(得分:2)

尝试使用不同的版本安装,这是因为某些时候二进制文件不适用于窗口的特定版本。

gem install mysql2 -v 0.2.6

如果问题仍然存在,请尝试以下步骤。

1)从http://dev.mysql.com/downloads/connector/c/

下载MySql C连接器

注意请勿下载安装程序,下载操作系统的ARCHIVE

2)将文件解压缩到C:\ mysql-connector

3)然后跑了:

 gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\lib" --with-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysql-connector"'

这对我有用。