Created
October 19, 2010 23:51
-
-
Save luislavena/635442 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}] |
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.
Hi Luis,
```
Thank you! This was VERY helpful!
For what it's worth, I'm running 32bit Windows 7/SP1.
Using the link you supplied and the MySQL Connector got the mysql
```
gem installed. Then I had issues getting mysql2 to work, finally solving
it with:
subst X: "C:\MySQLServer"
gem install mysql2 --platform=ruby -- --with-mysql-dir=X:
--with-mysql-lib=X:\lib
(From Ritesh's RoR Guide)
Note that with MySQL 5.5, there is no \lib\opt directory, so amend to
just \lib.
The --platform=ruby seems critical, too.
Thanks again for your help!
David
…On 5/22/2011 8:19 AM, luislavena wrote:
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.
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
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