Use MySQL DB for your rails Application ( Windows)

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.

Step -1:
$ 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.

Step-2:

Enter following Command in GitBash(StartMenu -> Search GitBash):

$  gem install mysql2 — ‘–with-mysql-lib=”c:Program FilesMySQLMySQL Server 5.5lib” –with-mysql-include=”c:Program FilesMySQLMySQL Server 5.5include”‘
 
#change command if your MySQL is  installed at different location.

Step-3:

Now copy libmysqld.dll file located at (C:program FilesMySQLMySQL Server 5.5 lib) to  (C:RailsInstallerRuby1.9.3bin) location.

Step-4:
$ 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.

Step-5:
Configure your mySQL_Example/app/configure/database.yml file :

Step-6: 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.

150 150 Burnignorance | Where Minds Meet And Sparks Fly!