Here I am assuming ruby on rails setup + MySQL Database has been installed in your windows machine.
We will follow couple of steps and will use MySQL Database for our rails application.
$ rails new mySQL_Example –database=mysql
#by applying –database=mysql parameter, check your Gemfile, it must include gem ‘mysql2’.
our procedure seems good still we’ll encounter following error
Never mind move to next step.
Enter following Command in GitBash(StartMenu -> Search GitBash):
$ 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”‘
#change command if your MySQL is installed at different location.
Now copy libmysqld.dll file located at (C:\program Files\MySQL\MySQL Server 5.5 \lib) to (C:\RailsInstaller\Ruby1.9.3\bin) location.
$ bundle install
#Now it’ll be successfull and mysql2 gem will be installed for our application.
#This copy of .dll file and bash configuration is just one time.
Configure your mySQL_Example/app/configure/database.yml file :
Now let’s create our DB, get a sample scaffold and migrate it to MySQL :
$ rake db:create
$ rails g scaffold project name:string description:text
$ rake db:migrate
#above commands will work perfectly if mySQL gem setup, proper configuration in database.yml has been done.
N.B.: Windows OS for rails app development is not advisaable, still if you got strict requirement then above steps will be helpful.