how to install mysql2 gem on windows/mingw32

Run the command – ‘gem install mysql2′

Got the following error-

D:\DEVKIT_INSTALL_DIR>gem install mysql2
Temporarily enhancing PATH to include DevKit…
Building native extensions. This could take a while…
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.

C:/Ruby192/bin/ruby.exe extconf.rb
pchecking for rb_thread_blocking_region()… yes
checking for main() in -llibmysql… no
p*** extconf.rb failed ***
pCould not create Makefile due to some reason, probably lack of
pnecessary libraries and/or headers. Check the mkmf.log file for more
pdetails. 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 C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.
3.6 for inspection.
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.6/ext/mysql2/gem_make.out

To solve the above issue follow the steps given below:

Download MySQL connector from Connector Download Link

Select file mysql-connector-c-noinstall-6.0.2-win32-vs2005.zip for download

Extract the zip file to C drive

Copy the libmysql.dll from mysql connector to ruby bin directory using following command

copy C:\mysql-connector-c-noinstall-6.0.2-win32\lib\libmysql.dll to C:\Ruby192\bin (If you have installed ruby in different location change the directory accordingly)

Run the following command

gem i mysql2 — ‘–with-mysql-dir=”c:\mysql-connector-c-noinstall-6.0.2-win32-vs2005″‘

Output should be as shown below

D:\DEVKIT_INSTALL_DIR>gem i mysql2 — –with-mysql-dir=”c:\mysql-connector-c-noinstall-6.0.2-win32-vs2005″‘
Temporarily enhancing PATH to include DevKit…
Building native extensions. This could take a while…
Successfully installed mysql2-0.3.6
1 gem installed
Installing ri documentation for mysql2-0.3.6…
Enclosing class/module ‘mMysql2′ for class Client not known
Installing RDoc documentation for mysql2-0.3.6…
Enclosing class/module ‘mMysql2′ for class Client not known

mysql2 gem installed sucessfully.
For more information, refer Wesley’s blog
http://zhangxh.net/programming/ruby/how-to-install-mysql2-gem-on-windows-mingw32/

你可能感兴趣的:(windows)