0
votes

I got some trouble when migrate Mysql and Rails

Information--------------------------

MySQL Server 5.5 (I had try MySQL Server 5.1, but not work)
Ruby 1.9.3-p429
Rails 3.2


I have already use

"gem install mysql2 -v 0.2.6"
"gem install mysql"

and add to gemfile

gem 'mysql'
gem 'mysql2','>=0.2.6'

I got error when I migrate database to MySQL
type "rake db:migrate"
and got Bad file descriptor

C:\Sites\demo> rake db:migrate
rake aborted!
Bad file descriptor
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

the detail

C:\Sites\demo> rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
Bad file descriptor
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mi
ngw32/lib/active_record/connection_adapters/mysql2_adapter.rb:312:in `query'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mi
ngw32/lib/active_record/connection_adapters/mysql2_adapter.rb:312:in `execute'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mi
ngw32/lib/active_record/connection_adapters/mysql2_adapter.rb:629:in `configure_
connection'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mi
ngw32/lib/active_record/connection_adapters/mysql2_adapter.rb:169:in `initialize
'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mi
ngw32/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mi
ngw32/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_conn
ection'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_co
nnection'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checko
ut_new_connection'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquir
e_connection'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `block
in checkout'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchr
onize'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checko
ut'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block
in connection'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchr
onize'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connec
tion'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrie
ve_connection'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/connection_handling.rb:79:in `retrieve_connection'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/connection_handling.rb:53:in `connection'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/migration.rb:863:in `initialize'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/migration.rb:764:in `new'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/migration.rb:764:in `up'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/migration.rb:742:in `migrate'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/
lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (requi
red)>'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/task.rb:236:in `call'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/task.rb:236:in `block in execute'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/task.rb:231:in `each'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/task.rb:231:in `execute'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/task.rb:175:in `block in invoke_with_call_chain'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchr
onize'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/task.rb:168:in `invoke_with_call_chain'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/task.rb:161:in `invoke'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/application.rb:149:in `invoke_task'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/application.rb:106:in `block (2 levels) in top_level'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/application.rb:106:in `each'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/application.rb:106:in `block in top_level'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/application.rb:115:in `run_with_threads'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/application.rb:100:in `top_level'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/application.rb:78:in `block in run'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/application.rb:165:in `standard_exception_handling'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rak
e/application.rb:75:in `run'
D:/AppServ/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/bin/rak
e:33:in `<top (required)>'
D:/AppServ/RailsInstaller/Ruby1.9.3/bin/rake:23:in `load'
D:/AppServ/RailsInstaller/Ruby1.9.3/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate

i have modify "database.yml"

development:
  adapter: mysql2
  encoding: utf8
  database: demo_development
  host: 127.0.0.1
  username: 'root'
  password: '1234'
  port: 3306

test:
  adapter: mysql2
  encoding: utf8
  database: demo_test
  host: 127.0.0.1
  username: 'root'
  password: '1234'
  port: 3306

production:
  adapter: mysql2
  encoding: utf8
  database: demo_production
  host: 127.0.0.1
  username: 'root'
  password: '1234'

Hoping someone could help me
I'm stock on it for several days
Thanks!

1

1 Answers

0
votes

try removing 'mysql' gem from gemfile, only 'mysql2' is required, after removing it do bundle install.

from the documentation of mysql on github

To use the Active Record driver (with or without rails), all you should need to do is have this gem installed and set the adapter in your database.yml to "mysql2". That was easy right? :)

NOTE: as of 0.3.0, and Active Record 3.1 - the Active Record adapter has been pulled out of this gem and into Active Record itself. If you need to use mysql2 with Rails versions < 3.1 make sure and specify gem "mysql2", "~> 0.2.7" in your Gemfile

also refer this for installing issues in windows

Rails installation windows 7 bad file descriptor mysql2