Windows 7 + Rails 3.0 + mysql2 Gem fix

Update: The Mysql2 Gem for windows has been officially released and its working like a charm, thanks to Brian Lopez for creating the gem, to install it just run “gem install mysql2″ and you are good to go. Happy coding!
If you are trying to install Rails on Windows 7, you are probably going to run into some problems most likely it’s going to be with the new mysql2. Right now it seems there is no working gem for windows but the good news is that you can still use the old mysql gem for your projects with little editing, following this simple steps:
  1. Make sure you are running Rails 3, Ruby 1.9.2 and that your gems are up to date, you can always run a quick — gem update –system
  2. Create your project as usual.
  3. Open your Gemfile with your favorite text editor and and make the following changes:
    /*Comment out the mysql2 line */
    #gem 'mysql2'
    /* Add the following line to use the old gem */
    gem 'mysql'
    
  4. Update your database.yml file and change any references to mysql2 to mysql.
I hope this saves you long hours of frustration.

Related Posts:

  • No Related Posts

, , ,

Comments (11)

    • October 20, 2010 at 1:00 pm

    Awesome. I did spend hours sifting through supposed fixes, but this will save me countless additional hours of frustration. Thanks Allan.

    Reply

    • December 23, 2010 at 3:44 pm

    Where can I find the Gemfile

    Reply

    • February 20, 2011 at 9:29 pm

    Thanks for the tip.
    I spent a few hours at it before I found ya.

    Reply

  • Very, very, very useful, thanks!

    Reply

    • April 12, 2011 at 11:08 pm

    It didn’t worked for me.
    I get an error while using db:migrate

    Reply

    • May 3, 2011 at 12:38 pm

    Please let me know is the gem2 version is available for windows

    Ashu

    Reply

    • May 4, 2011 at 1:12 am

    Can you please let me know few difference /advantage between mysql and mysql2 gem

    Ashu

    Reply

    • @Ashu, The mysql2 gem has been available for windows for quite a while now you can get it through gem or go to the github repository. Cheers!

      Reply

    • July 12, 2011 at 7:23 pm

    i wanted to use your rss Feed but it shows me some XML errors..

    Reply

    • July 13, 2011 at 2:55 pm

    Here is how to install mysql2:

    $ gem install mysql2 — ‘–with-mysql-lib=”c:\Program Files\MySQL\MySQL Server 5.5\lib” –with-mysql-include=”c:\Program Files
    \MySQL\MySQL Server 5.5\include”‘
    Temporarily enhancing PATH to include DevKit…
    Building native extensions. This could take a while…
    Successfully installed mysql2-0.3.6
    1 gem installed
    Installing ri documentation for mysql2-0.3.6…
    Enclosing class/module ‘mMysql2′ for class Client not known
    Installing RDoc documentation for mysql2-0.3.6…
    Enclosing class/module ‘mMysql2′ for class Client not known

    Reply

      • July 13, 2011 at 2:56 pm

      Sorry the format was damaged. Here is it:

      $ gem install mysql2 — ‘–with-mysql-lib=”c:\Program Files\MySQL\MySQL Server 5.5\lib” –with-mysql-include=”c:\Program Files
      \MySQL\MySQL Server 5.5\include”‘

      Reply

Post A Comment