Install Rails with MySql on Windows

Hello Ruby guys!

It had been 4 years before last year I used Ubuntu or MacOS for Ruby on Rails development. It is absolutely that Linux environment is much easier for developers than Windows. The only thing that make me switch from Linux to Windows is that documentation on Windows is much more comfortable.

At first, I tried to use Vmware to install a virtual Ubuntu and program on that operating system. However, problem occurs. I cannot work on virtual machine for long duration, my computer get slower after several hours.

Thus, it’s critical to program Ruby on Rails directly on Windows. After several tries, finally I got a brief note of steps

  1. You should install Ruby and then install rails as gem, instead of using rails installer. You can install latest ruby version on https://rubyinstaller.org/downloads/. You can choose to install along with DevKit. Just follow the ruby installation guide, and remember to choose MSYS development tool when install devkit
  2. Install Git Bash to work with git on command line as on Linux terminal and to have another cool terminal. Many people might prefer using Git tool like SourceTree, SmartGit, etc … It’s your choice.
  3. Open Ruby Command Prompt or Git Bash terminal, test your ruby installation by
     gem install json --platform=ruby --no-ri --no-rdoc
  4. Install XAMPP, the easiest way to have mysql and mysql management tool (phpmyadmin)
  5. Download C connecter , extract to
    C:\

    and copy

    libmysql.dll

    from

    C:\mysql-connector-c-noinstall-6.0.2-win32\lib

    to your ruby installation directory

    C:\Programs\Ruby25\bin
  6. Install rails gem
    gem install rails --platform=ruby --no-ri --no-rdoc
  7. Install mysql2 gem to be able to use mysql as database for your rails project
    gem install mysql2 --platform=ruby --no-ri --no-rdoc
  8. Create new rails project with mysql as database
    rails new ProjectName -d mysql

Happy Coding!


Published by

Colin Dao

I am a hardworking Rubyist in Hanoi, Vietnam

Leave a comment