Ruby MYSQL2 gem installation on windows 7

2019-01-03 23:40发布

I'm trying to installing the mysql2 gem on windows 7 I downloaded the connector from the mysql site and placed the libmysql.dll in ruby200\bin

then do gem install mysql2

These are the results am I being dim here?

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:/Ruby200/bin/ruby.exe extconf.rb
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
*** 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:/Ruby200/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}/
extconf.rb:37:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError
)


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

标签: ruby gem mysql2
16条回答
仙女界的扛把子
2楼-- · 2019-01-03 23:50

I am still having problem with mysql2 gem but below approach helped me install mysql with RoR on Windows Env.

Step 1 : Gem File changes : ({app}/Gemfile)

Update mysql2 --> mysql

Step 2 : Updates in database.yml file ({app}/config/database.yml)

Change adapter: mysql2 --> adapter: mysql

host: localhost --> host: 127.0.0.1

Step 3 : Downoad mysql-connector-c-noinstall-6.0.2-win32

Step 4 : Copy mysql-connector-c-noinstall-6.0.2-win32\lib\libmysql.dll file to C:\RailsInstaller\Ruby1.9.3\bin

Step 5 :bundle update && Start rails server

查看更多
孤傲高冷的网名
3楼-- · 2019-01-03 23:52

Steps for Ruby 2.1.3, Windows 8.1 and MySQL Server 5.7. All x64 bit.

  1. Download Development Kit
  2. Extracted Development Kit.
  3. Run CMD and go to dir where is Development Kit extracted
  4. Run ruby dk.rb init
  5. Run ruby dk.rb install
  6. Run gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.7\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.7\include" --with-mysql-dir="c:\Program Files\MySQL\MySQL Server 5.7"'
查看更多
地球回转人心会变
4楼-- · 2019-01-03 23:52

I have tried all provided methods but the same error appears again and again :(

Fortunately, older version installed without any errors!

gem uninstall mysql2
gem install mysql2 -v 0.2.6
查看更多
▲ chillily
5楼-- · 2019-01-03 23:53

I managed to succeed at this out of pure luck, but after an hour of hell I feel like I should share my solution, obviously very shortened but a lot of the steps I think you can figure out how to do on your own.

My machine is Win 7 64bit. I was able to install version 0.3.16

  1. Install ruby version 2.0.0p481 (?)
  2. Devkit blah blah
  3. Install rails version 4.0.0
  4. Download Mysql Connector C 64 bit zip file, put in C drive as mysqlc
  5. Take DLL from that bin, put it in lib of ruby
  6. gem install mysql2 -- -- with-mysql-dir="C:\mysqlc"
查看更多
叼着烟拽天下
6楼-- · 2019-01-03 23:53

Here is what I did for windows server 2012 sp2. Nothing else worked...

After receiving error 'while installing mysql2 (0.3.17), and bundler cannot continue' Make sure that 'gem install mysql2 -v '0.3.17' succeeds...

1) Download the MySql C Connector from: http://dev.mysql.com/downloads/connector/c/

2) Extract the file to C:\mysql-connector

3) gem install mysql2 -v '0.3.17' --platform=ruby -- '--with-mysql-dir="C:\mysql-connector"'

Note: the -v '0.3.17' above, it would not work without this.

4) bundle install --> Finally, Success.

查看更多
看我几分像从前
7楼-- · 2019-01-03 23:55

Here's what worked for me:

gem install mysql2 -- '--with-mysql-dir="C:\wamp\bin\mysql\mysql5.5.xx"'

Been searching for a few hours and not seen this variation suggested, so hopefully it will help someone!

查看更多
登录 后发表回答