简体   繁体   English

使用windows安装mysql2时出错

[英]Error installing mysql2 with windows

It's strange the I can install mysql2 with this command: $ 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"' Following is the results: 奇怪的是我可以用这个命令安装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...

But when I'm running bundle install (apperently I have a lot of gems needs to install), it is failed to install mysql2, so bundle install stopped there, that really drives me crazy... anyone could help? 但是当我运行bundle install (显然我需要安装很多gem),它无法安装mysql2,所以bundle install停在那里,这真让我疯狂......任何人都可以帮忙吗? a tons of thanks! 多谢了! Below is the result from 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.

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

Try this installing mysql from outside the bundle and if it works remove mysql from Gemfile 尝试从捆绑包外部安装mysql,如果可以的话,从Gemfile中删除mysql

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

--with-mysql-config=/usr/local/mysql/bin/mysql_config --with MySQL的-配置=的/ usr /本地/ MySQL的/斌/ mysql_config

Also

apt-get install libmysqld-dev

Works fines, please download the version mysql-connector-c-6.1.5-win32, unzip on the folder, and try this. 罚款,请下载mysql-connector-c-6.1.5-win32版本,解压缩该文件夹,然后试试这个。

Works well for me. 对我来说效果很好。

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 gem install mysql2 --no-ri --no-rdoc --platform = ruby​​ - --with-mysql-include = C:\\ mysql-connector \\ mysql-connector-c-6.1.5-win32 \\ include - 与MySQL的-LIB = C:\\ MySQL的连接器\\ MySQL的连接器-C-6.1.5-的win32 \\ lib中

The version of mysql2 gem you're trying to install have issues on Windows. 您尝试安装的mysql2 gem版本在Windows上存在问题。

Please install mysql2 gem without indicating the version: 请安装mysql2 gem而不指明版本:

gem install mysql2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM