Skip to content

Instantly share code, notes, and snippets.

@luislavena
Created October 19, 2010 23:51
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luislavena/635442 to your computer and use it in GitHub Desktop.
Save luislavena/635442 to your computer and use it in GitHub Desktop.
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}]
Copy link

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

@luislavena
Copy link
Author

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.

Copy link

ghost commented May 24, 2011 via email

@luislavena
Copy link
Author

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