很奇怪,我可以用这个命令安装mysql2:$ gem install mysql2 --platform=ruby -- '--with-mysql-lib="c:Program FilesMySQLMySQL Server 5.5lib" --with-mysql-include="c:Program FilesMySQLMySQL Server 5.5include"'
结果如下:
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.
在我的ubuntu机器上,必须先运行apt-get install libmysqld-dev
,然后运行gem install mysql2
…
尝试从包外安装mysql,如果成功,将mysql从Gemfile中移除
sudo gem install mysql --no-rdoc --no-ri --
——with-mysql-config =/usr/地方/mysql/bin/mysql_config
也apt-get install libmysqld-dev
您要安装的mysql2 gem版本在Windows上有问题
请安装mysql2 gem,不注明版本:
gem install mysql2
工作正常,请下载mysql-connector-c-6.1.5-win32版本,在文件夹上解压缩,并尝试这个
很适合我。
gem install mysql2——no-ri——no-rdoc——platform=ruby -- --with-mysql-include=C:mysql-connectormysql-connector- C -6.1.5-win32lib