-
-
Save donhuvy/2f54917f1f5b3f0e1259901b08c88bb6 to your computer and use it in GitHub Desktop.
Installing Ruby, Rails, and mysql gem on Windows
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
Install Ruby using rubyinstaller: | |
http://rubyinstaller.org/downloads/ | |
install to the C drive to a folder without spaces, eg c:/Ruby193 | |
Install RubyGems: | |
http://rubyforge.org/frs/?group_id=126 | |
on command line do: | |
'gem install rails' | |
Install DevKit from: | |
http://rubyonrails.org/download | |
following these instructions: https://github.com/oneclick/rubyinstaller/wiki/Development-Kit | |
Install the latest version of MySQL Community Server: | |
http://dev.mysql.com/downloads/mysql | |
Install the no-install MySQL connector following these instructions from http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/: | |
Update: mysql gem version `2.9.0` already fix the issues shown here. Install it normally and follow the on-screen instructions. | |
In order to use my brand new MySQL installation, now I need to install the MySQL bindings for it. | |
But, there is a small detail: Ruby is 32bits and my MySQL is 64bits, this means I can’t use MySQL provided libraries from Ruby. | |
Bummer! You told me to install the 64bits version! | |
Don’t despair! MySQL Connector to the rescue! | |
That is right, MySQL has something called Connector, the purpose of that library is to avoid a complete MySQL installation when you just need to connect to a remote one. | |
It comes in different flavors, we are interested in C language support, since that is the language Ruby uses for it’s extensions. | |
We are going to download a 32bits connector and use it! | |
So, at my web browser again, decided to visit the MySQL Connector/C download page: | |
http://dev.mysql.com/downloads/connector/c/ | |
Since I’m not interested in installing this Connector and pollute my clean 64bits installation, I’m going to download the non-installer version. | |
I scrolled down the listing until I saw the noinstall 32bits version: | |
mysql-connector-c-noinstall-6.0.2-win32.zip | |
Decided to extract it to the root of my disk, so I ended with a folder named mysql-connector-c-noinstall-6.0.2-win32 in there. | |
Remember: extract into a folder without spaces (something like c:\mysqlconnector\). The same goes for your Ruby installation and the DevKit installation. | |
Hit the Windows button and type Ruby, open "Command Prompt with Ruby and Rails" | |
type "where libmysql.dll" | |
it should show up ONLY in your RailsInstaller\Ruby1.9.3\bin\ directory | |
if it's anywhere else, find the file on your computer and rename it temporarily. | |
Then run these two commands with the directory you extracted the mysql connector to: | |
gem install mysql --platform=ruby -- --with-mysql-lib=C:/mysqlconnector/lib --with-mysql-include=C:/mysqlconnector/include | |
gem install mysql2 --platform=ruby -- --with-mysql-lib=C:/mysqlconnector/lib --with-mysql-include=C:/mysqlconnector/include | |
If it works, type 'require mysql'. You'll likely get an error that libmysql.dll is missing. Add the file from the mysqlconnector/lib folder to your Ruby\bin folder and windows\system32 folder. | |
type require mysql again and it should work | |
Resources: | |
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit | |
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/ | |
http://stackoverflow.com/questions/8740868/mysql2-gem-compiled-for-wrong-mysql-client-library | |
http://dev.mysql.com/downloads/connector/c/ | |
https://groups.google.com/forum/?fromgroups=#!searchin/rubyinstaller/mysql$20windows/rubyinstaller/DTSQdQjX8bY/MgiNW7CMO4oJ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment