Unable to use mysql with rails

Hi All,
I successfully installed rails(3.0.10) and ruby version
1.9.2 and mysql version 5.5.8 on my windows7 machine. I am using
mysisgit also.
i am able to start any application with sqlite3 which comes default
for rails. But problem is when i want use mysql.
i am using

“rails new appname -d mysql” for using mysql
$ rails new appname -d mysql
create
create README
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/mailers
create app/models
create app/views/layouts/application.html.erb
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/secret_token.rb
create config/initializers/session_store.rb
create config/locales
create config/locales/en.yml
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create doc
create doc/README_FOR_APP
create lib
create lib/tasks
create lib/tasks/.gitkeep
create log
create log/server.log
create log/production.log
create log/development.log
create log/test.log
create public
create public/404.html
create public/422.html
create public/500.html
create public/favicon.ico
create public/index.html
create public/robots.txt
create public/images
create public/images/rails.png
create public/stylesheets
create public/stylesheets/.gitkeep
create public/javascripts
create public/javascripts/application.js
create public/javascripts/controls.js
create public/javascripts/dragdrop.js
create public/javascripts/effects.js
create public/javascripts/prototype.js
create public/javascripts/rails.js
create script
create script/rails
create test
create test/fixtures
create test/functional
create test/integration
create test/performance/browsing_test.rb
create test/test_helper.rb
create test/unit
create tmp
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create vendor/plugins
create vendor/plugins/.gitkeep

Then “cd appname” and
Then “bundle install”

$ bundle install
Fetching source index for http://rubygems.org/
Using rake (0.9.2)
Using abstract (1.0.0)
Using activesupport (3.0.10)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.10)
Using erubis (2.6.6)
Using rack (1.2.3)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.29)
Using actionpack (3.0.10)
Using mime-types (1.16)
Using polyglot (0.3.2)
Using treetop (1.4.10)
Using mail (2.2.19)
Using actionmailer (3.0.10)
Using arel (2.0.10)
Using activerecord (3.0.10)
Using activeresource (3.0.10)
Using bundler (1.0.18)
Installing mysql2 (0.2.13) with native extensions c:/Ruby192/lib/ruby/
1.9.1/ruby
gems/installer.rb:483:in `rescue in block in build_extensions’: ERROR:
Failed to
build gem native extension. (Gem::Installer::ExtensionBuildError)

c:/Ruby192/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()… yes
checking for main() in -llibmysql… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=c:/Ruby192/bin/ruby
–with-mysql-dir
–without-mysql-dir
–with-mysql-include
–without-mysql-include=${mysql-dir}/include
–with-mysql-lib
–without-mysql-lib=${mysql-dir}/lib
–with-libmysqllib
–without-libmysqllib

Gem files will remain installed in c:/Ruby192/lib/ruby/gems/1.9.1/gems/
mysql2-0.
2.13 for inspection.
Results logged to c:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.13/
ext/mysql2/g
em_make.out
from c:/Ruby192/lib/ruby/1.9.1/rubygems/installer.rb:486:in
block in bu ild_extensions' from c:/Ruby192/lib/ruby/1.9.1/rubygems/installer.rb:446:in each’
from c:/Ruby192/lib/ruby/1.9.1/rubygems/installer.rb:446:in
build_exten sions' from c:/Ruby192/lib/ruby/1.9.1/rubygems/installer.rb:198:in install’
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/
bundler/sour
ce.rb:101:in block in install' from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/ bundler/ruby gems_integration.rb:78:in preserve_paths’
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/
bundler/sour
ce.rb:91:in install' from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/ bundler/inst aller.rb:58:in block (2 levels) in run’
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/
bundler/ruby
gems_integration.rb:93:in with_build_args' from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/ bundler/inst aller.rb:57:in block in run’
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/
bundler/inst
aller.rb:49:in run' from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/ bundler/inst aller.rb:8:in install’
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/
bundler/cli.
rb:220:in install' from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/ bundler/vend or/thor/task.rb:22:in run’
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/
bundler/vend
or/thor/invocation.rb:118:in invoke_task' from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/ bundler/vend or/thor.rb:263:in dispatch’
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/
bundler/vend
or/thor/base.rb:386:in start' from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/bin/ bundle:13:in <top (required)>’
from c:/Ruby192/bin/bundle:19:in load' from c:/Ruby192/bin/bundle:19:in

and then “rails s”

$ rails s
←[31mCould not find gem ‘mysql2 (~> 0.2.11, runtime)’ in any of the
gem sources
listed in your Gemfile.←[0m
←[33mRun bundle install to install missing gems.←[0m

and one more thing i noticed here is
i am not able to find the version of rails when i am in the root, see
this

$ rails -v
←[31mCould not find gem ‘mysql2 (~> 0.2.11, runtime)’ in any of the
gem sources
listed in your Gemfile.←[0m
←[33mRun bundle install to install missing gems.←[0m

But i am able find it when outside the application
$ rails -v
Rails 3.0.10

so thats the error i am getting. i tried different methods by
googling, but nothing worked out for me.
I am still in my initial days and any help would be appreciated.

Tried that but no luck…

Problem is that mysql2 gem is not installed…
Install mysql2 gem with source as path to mysql in order top install it
properly

On Wed, Sep 7, 2011 at 7:24 PM, venkata reddy
[email protected]wrote:

 create
 create  app/views/layouts/application.html.erb
 create  config/initializers/inflections.rb
 create  doc/README_FOR_APP
 create  public/422.html
 create  public/javascripts/controls.js
 create  test/performance/browsing_test.rb

Using activemodel (3.0.10)
Using actionmailer (3.0.10)
c:/Ruby192/bin/ruby.exe extconf.rb
–with-opt-include
–with-mysql-include
Results logged to c:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.13/
from c:/Ruby192/lib/ruby/1.9.1/rubygems/installer.rb:198:in
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/
aller.rb:49:in run' bundler/vend from c:/Ruby192/bin/bundle:19:in load’
and one more thing i noticed here is
$ rails -v
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


sαη∂ιρ Rαηѕιηg


twitter, github @sandipransing
skype sandip.ransing

On Sep 7, 10:54 am, venkata reddy [email protected] wrote:

Hi All,
I successfully installed rails(3.0.10) and ruby version
1.9.2 and mysql version 5.5.8 on my windows7 machine. I am using
mysisgit also.
i am able to start any application with sqlite3 which comes default
for rails. But problem is when i want use mysql.
i am using

“rails new appname -d mysql” for using mysql
$ rails new appname -d mysql

Short answer:

Install either mysql or mysql2 gem following these instructions:
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/

Long answer:

Rails is defaulting to mysql2 and attempting to compile latest
version.

Gem compilation will attempt to find libmysql and headers to link to,
but these are not available unless you supply the --with-mysql-dir
option during gem installation.

Since Bundler doesn’t support that, you should install the gem prior
doing the bundle install, which will solve Bundler attempting to
download and install the gem again.

The provided tutorial will work with any version of MySQL installed
since it will not use any file from it. Instead, it will use the
standalone Connector component, which gives you freedom to update
MySQL later.

But i am able find it when outside the application
$ rails -v
Rails 3.0.10

That is because you’re inside an application folder and “rails” will
attempt to run in the context of your application (so rails generate,
rails server and others) work.

Hope this helps.

Cheers,

Luis L.

hey

do one thing use rails version 3.0.9( which is stable) and change in
gem
file as mysql “0.2.6” rails “3.0.9” then start bundle install then
start
the server.

thanks
ravinder reddy

On Thu, Sep 8, 2011 at 12:54 AM, Varunkumar varoon
[email protected]wrote:

Gem files will remain installed in
ach’
C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/ruby
from
rb:220:in `install’
C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/vend
Ruby: c:\Ruby191
You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


Thanks & regds
Ravinder k

Hi Luis,
Thanks for your time. But still i am not able to do…getting panic
with rails on windows…

Hi,

I believe that my problem will be solved form now!!

I have created a rails projects as “rails new Tickets” I need to make my
app. mysql compatible. I did the changes in gemfile

source ‘http://rubygems.org

gem “rails”, “3.0.0.rc”

Bundle edge Rails instead:

gem ‘rails’, :git => ‘git://github.com/rails/rails.git’

gem ‘mysql2’, ‘< 0.3’

but when i tire bundle install, i got the error as

Gem files will remain installed in
C:/Ruby191/lib/ruby/gems/1.9.1/gems/mysql2-0.
2.13 for inspection.
Results logged to
C:/Ruby191/lib/ruby/gems/1.9.1/gems/mysql2-0.2.13/ext/mysql2/g
em_make.out
from
C:/Ruby191/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:486:in b lock in build_extensions' from C:/Ruby191/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:446:in e
ach’
from
C:/Ruby191/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:446:in b uild_extensions' from C:/Ruby191/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:198:in i
nstall’
from
C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/sour
ce.rb:101:in block in install' from C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/ruby gems_integration.rb:78:in preserve_paths’
from
C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/sour
ce.rb:91:in install' from C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/inst aller.rb:58:in block (2 levels) in run’
from
C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/ruby
gems_integration.rb:93:in with_build_args' from C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/inst aller.rb:57:in block in run’
from
C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/inst
aller.rb:49:in run' from C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/inst aller.rb:8:in install’
from
C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/cli.
rb:220:in install' from C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/vend or/thor/task.rb:22:in run’
from
C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/vend
or/thor/invocation.rb:118:in invoke_task' from C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/vend or/thor.rb:263:in dispatch’
from
C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/vend
or/thor/base.rb:386:in start' from C:/Ruby191/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/bin/bundle:13:in <top (required)>’
from C:/Ruby191/bin/bundle:19:in load' from C:/Ruby191/bin/bundle:19:in

Config details

Ruby: c:\Ruby191
Rails : 3.0.10
Mysql: 5.5.15

Thanks in ADVANCE

Easiest way to get it to work would be to use mysql gem instead of
mysql2
gem.
Open up your Gemfile and replace
gem ‘mysql2’, ‘~> 0.2.11’
with
gem ‘mysql’

And open up your database.yml fine and change adapter from mysql2 to
mysql

Chirag
http://sumeruonrails.com

Yes that successfully starts the server.
But when i see my application environment

RuntimeError

Please install the mysql2 adapter: gem install activerecord-mysql2- adapter (no such file to load – active_record/connection_adapters/
mysql2_adapter)
Rails.root: c:/rails/appname

Application Trace | Framework Trace | Full Trace
Request

Parameters:

None
Show session dump

Show env dump

Response

Headers:

None
Getting started
Here’s how to get rolling:

Use rails generate to create your models and controllers
To see all available options, run it without parameters.

Set up a default route and remove or rename this file
Routes are set up in config/routes.rb.

Create your database
Run rake db:migrate to create your database. If you’re not using
SQLite (the default), edit config/database.yml with your username and
password.

You have to change your config/database.yml file also.
Open that and replace “mysql2” with “mysql” everywhere.

Chirag
http://sumeruonrails.com

Anybody using rails 3.0.10 and ruby1.9.2 with mysql 5.5.8 on 32 bit
windows7?

yes you are right that made displaying my environment clear but one
more issue when i run rake db:migrate is

$ bundle exec rake db:migrate
rake aborted!
Mysql::Error: query: not connected: SHOW TABLES

Tasks: TOP => db:migrate
(See full trace by running task with --trace)

On Thu, Sep 8, 2011 at 2:27 PM, venkata reddy
[email protected]wrote:

There are two things you will have to check for this:

  1. Have you configured correct username and password in your
    config/database.yml file for your development database or not?
  2. Have you created the development database yet or not? Try rake
    db:create

If those don’t work, then run the with --trace option at the end and
paste
the result here.

Chirag
http://sumeruonrails.com

On Sep 8, 4:17am, venkata reddy [email protected] wrote:

Hi Luis,
Thanks for your time. But still i am not able to do…getting panic
with rails on windows…

Panic you mean a segmentation fault? I’m guessing because you’re not
proving the real error messages.

Please ensure libmysql.dll from the MySQL Connector/C package is
copied into Ruby bin directory (as the instructions of my blog
article).


Luis L.

I configured correct username and password
I created the development database appname_development

result of rake db:migrate is as follows
$ rake db:migrate
(in c:/rails/appname)
rake aborted!
uninitialized constant Rake::DSL
c:/Ruby192/lib/ruby/1.9.1/rake.rb:2482:in const_missing' c:/rails/appname/rails/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb: 8:in
c:/rails/appname/rails/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:
6:in <mod ule:Rake>' c:/rails/appname/rails/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb: 3:in<top
(required)>’
c:/rails/appname/rails/ruby/1.9.1/gems/rdoc-3.9.4/lib/rdoc/task.rb:
37:in requir e' c:/rails/appname/rails/ruby/1.9.1/gems/rdoc-3.9.4/lib/rdoc/task.rb: 37:in<top (
required)>’
c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/tasks/
documenta
tion.rake:2:in require' c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/tasks/ documenta tion.rake:2:in<top (required)>’
c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/
tasks.rb:15:in
load' c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/ tasks.rb:15:inblock in <top (required)>’
c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/
tasks.rb:6:in each' c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/ tasks.rb:6:in
<top (required)>’
c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/
application.rb:
215:in require' c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/ application.rb: 215:ininitialize_tasks’
c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/
application.rb:
139:in load_tasks' c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/ application.rb: 77:inmethod_missing’
c:/rails/appname/Rakefile:7:in <top (required)>' c:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:inload’
c:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:in raw_load_rakefile' c:/Ruby192/lib/ruby/1.9.1/rake.rb:2007:inblock in load_rakefile’
c:/Ruby192/lib/ruby/1.9.1/rake.rb:2058:in
standard_exception_handling' c:/Ruby192/lib/ruby/1.9.1/rake.rb:2006:inload_rakefile’
c:/Ruby192/lib/ruby/1.9.1/rake.rb:1991:in run' c:/Ruby192/bin/rake:31:in

Here is rake db:migrate with trace

$ rake db:migrate --trace
(in c:/rails/appname)
rake aborted!
uninitialized constant Rake::DSL
c:/Ruby192/lib/ruby/1.9.1/rake.rb:2482:in const_missing' c:/rails/appname/rails/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb: 8:in
c:/rails/appname/rails/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:
6:in <mod ule:Rake>' c:/rails/appname/rails/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb: 3:in<top
(required)>’
c:/rails/appname/rails/ruby/1.9.1/gems/rdoc-3.9.4/lib/rdoc/task.rb:
37:in requir e' c:/rails/appname/rails/ruby/1.9.1/gems/rdoc-3.9.4/lib/rdoc/task.rb: 37:in<top (
required)>’
c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/tasks/
documenta
tion.rake:2:in require' c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/tasks/ documenta tion.rake:2:in<top (required)>’
c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/
tasks.rb:15:in
load' c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/ tasks.rb:15:inblock in <top (required)>’
c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/
tasks.rb:6:in each' c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/ tasks.rb:6:in
<top (required)>’
c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/
application.rb:
215:in require' c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/ application.rb: 215:ininitialize_tasks’
c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/
application.rb:
139:in load_tasks' c:/rails/appname/rails/ruby/1.9.1/gems/railties-3.0.10/lib/rails/ application.rb: 77:inmethod_missing’
c:/rails/appname/Rakefile:7:in <top (required)>' c:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:inload’
c:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:in raw_load_rakefile' c:/Ruby192/lib/ruby/1.9.1/rake.rb:2007:inblock in load_rakefile’
c:/Ruby192/lib/ruby/1.9.1/rake.rb:2058:in
standard_exception_handling' c:/Ruby192/lib/ruby/1.9.1/rake.rb:2006:inload_rakefile’
c:/Ruby192/lib/ruby/1.9.1/rake.rb:1991:in run' c:/Ruby192/bin/rake:31:in

Looks like the issue is because you are using wrong version of rake.
Either uninstall rake 0.9.2
or run any rake commands with a “bundle exec” prefix
like this
bundle exec rake db:migrate
bundle exec rake db:create

Chirag
http://sumeruonrails.com

Actually i am copying what ever the error i got and pasting here.
i already copied libmysql.dll into ruby bin directory.

It is eating lot of time. I think i should move to linux. Rails on
windows sucks…

when i go for bundle exec rake db:migrate

$ bundle exec rake db:migrate
rake aborted!
Mysql::Error: query: not connected: SHOW TABLES

Tasks: TOP => db:migrate
(See full trace by running task with --trace)

i tried it in the first step. This is the error i got.
You know some time ago when rails 3.0.3 i successfully did all this.
But now i don’t know what’s changed,i am trying in different ways
still no luck.
The only reason i am still fighting with is " i love rails"

On Sep 8, 8:09am, venkata reddy [email protected] wrote:

Actually i am copying what ever the error i got and pasting here.
i already copied libmysql.dll into ruby bin directory.

It is eating lot of time. I think i should move to linux. Rails on
windows sucks…

Yeah, learn bash, GNOME, apt, install gcc and of course configure RVM,
that is way faster than this, sure.

/sarcasm

If you had used RailsInstaller you would have all the things you need
to successfully run a Rails project. RubyInstaller is the building
block of it.

Yet still, install gems that require compilation and depend on other
things, no matter what platform you are they could baffle you.

Install Linux and let us know how it goes.


Luis L.

Hi reddy,
I came across this problem several days ago,I’m using windows
xp ,Here is my solution.

 1. edit Gemfile => gem 'mysql2', '0.2.6'
 2. download  mysql-noinstall-5.1.50-win32.zip  at

http://downloads.mysql.com/archives/mysql-5.1/mysql-noinstall-5.1.50-win32.zip
,unzip
3. gem install mysql2 -v 0.2.6 – --with-mysql-lib=E:\ROR
\mysql-5.1.50-win32\lib --with-mysql-include=E:\ROR\mysql-5.1.50-
win32\include (replace the file “E:\ROR\mysql-5.1.50-win32” path with
yours)
4. this should work now,try bundle install,generate some
model ,and run rake db:migrate to see if it works,make sure your
database config is right,like this
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: depot_development
pool: 5
username: root
password: root
host: localhost
5.if it still not work ,try this =>

Hope this helped