Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
C:\Users\Luis>ruby -v
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]
C:\Users\Luis>gem install mysql2 --platform=ruby -- --with-mysql-include=C:\mysql-5.1.51-win32\include --with-mysql-lib=C:\mysql-5.1.51-win32\lib\opt
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed mysql2-0.2.5
1 gem installed
C:\Users\Luis>irb
irb(main):001:0> require 'mysql2'
=> true
irb(main):002:0> client = Mysql2::Client.new(:host => "localhost", :username => "root", :database => 'foo_dev')
irb(main):003:0> results = client.query("SELECT COUNT(id) FROM users")
=> #<Mysql2::Result:0x2bd9148>
irb(main):004:0> results.map { |r| r }
=> [{"COUNT(id)"=>0}]
@ghost

ghost commented May 22, 2011

Hi Luis,
I'm not getting this mysql2 to build properly. I'm running Ruby 1.9.2, and Rails 3.0.7. I managed to get the sqlite3 gem built, but I'm getting the 'mysql.h missing' error. I changed your 'gem install' to properly point to \lib, instead of \lib\opt, as there is no \lib\opt in the MySQL 5.5 install directory structure. Any ideas? Is this problem reintroduced by MySQL 5.5?
Thanks

Owner

luislavena commented May 22, 2011

Can you please follow the instructions here?

https://github.com/oneclick/rubyinstaller/wiki/Troubleshooting#gems_mix_bits

Download the 32bits version of MySQL Connector/C.

@ghost

ghost commented May 24, 2011

Owner

luislavena commented Jul 8, 2011

For those interested in a complete guide to MySQL installation on Windows, I wrote an article on my blog:

http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment