1

Environment:

Windows 7 64bit (Home Premium)

Ruby 1.9.2 p290 (2011-07-09) [i386-mingw32]

Rails 3.0.10

MySQL 5.5

Ruby, despite my having successfully installed the mysql2 rubygem thinks that the gem is missing when I invoke a rails command that requires it.

After having spent the evening getting the mysql rubygem installed on Windows 64 bit, I decided to (finally) get cracking on linking mysql to a local rails server. This is how I was trying to do it...

(Fairly) Exact transcript from cmd.exe

C:\rails\cookbook>gem install mysql --platform=ruby -- --with-mysql-include=c:\mysql\include --with-mysql-lib=c:\mysql\lib
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...
Installing RDoc documentation for mysql-2.8.1...
(I thought this was successful mysql install, should I test it somehow?)

C:\>gem install mysql2 --platform=ruby -- --with-mysql-include=c:\mysql\include --with-mysql-lib=c:\mysql\lib
Fetching: mysql2-0.3.7.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.7
1 gem installed
Installing ri documentation for mysql2-0.3.7...
Enclosing class/module 'mMysql2' for class Client not known
Installing RDoc documentation for mysql2-0.3.7...
Enclosing class/module 'mMysql2' for class Client not known
(Same as above - I thought this was successful mysql install)

C:\rails>rails new cookbook -d mysql
(successfully creates directories for project in c:\rails\cookbook)

C:\rails\cookbook>rails server
?[31mCould not find gem 'mysql2 (~> 0.2.11)' in any of the gem sources listed in your Gemfile.?[0m
?[33mRun `bundle install` to install missing gems.?[0m

Notes: I noticed it wants rubygem mysql2-0.2.11, I have 0.3.7. I tried installing 0.2.11 specifically by the method I used to install the two gems above. No dice, it couldn't find a gem by the name mysql2-0.2.11 in 'any repository'

I'm stumped, any thoughts fellas (and gals)?

basicxman
  • 2,095
  • 14
  • 21
Northorn
  • 11
  • 1
  • 2
  • 2
    Windows isn't the best platform for ruby web development. I suggest making a Linux VM with VirtualBox and Vagrant (http://vagrantup.com/) unless you have a specific need to run on Windows. If your actual deployment environment is Linux it certainly is in your best interest to develop in a Linux VM so your production and dev envs are as close as possible. I don't think you'll run into any of these problems with a Linux box as that's what most developers use and you'll be able to get more access to help. – six8 Sep 07 '11 at 03:17
  • @Cixate or at the minimum something like sqlite3 which has much more mature integration with Windows + RoR – basicxman Sep 07 '11 at 03:19

3 Answers3

2

I believe your MySQL installation is a 64bits (like Windows), correct?

Ruby is 32bits, so you cannot link 32bits against 64bits.

I've posted a article covering the installation steps on my blog:

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

These steps use MySQL Connector/C to workaround the 32bits versus 64bits issues.

Both mysql or mysql2 gem should work with this.

Luis Lavena
  • 10,348
  • 1
  • 37
  • 39
0

@@ my sql installation (on 64 bit architecture)

download connector (download zip file and extract it to c drive)

http://dev.mysql.com/downloads/connector/c/

download mysql

http://dev.mysql.com/downloads/installer/5.6.html

command to install mysql with connector

C:\Sites\rails_project\resume>gem install mysql --platform=ruby -- --with-mysql-
dir=C:/mysql-connector-c-6.1.0-win32

After this copy libmysql.dll from connector folder and paste it to ruby>bin folder

Community
  • 1
  • 1
Tarun Gupta
  • 6,305
  • 2
  • 42
  • 39
0

Have you included mysql2 in your Gemfile and subsequently executed bundle install ?

thejspr
  • 139
  • 1
  • 7