Nov 28, 2010

Not able to create DataBase : "MySQL and Rails3" ?

Not able to create DB : MySQL and Rails3 ?
For all those who have migrated from Rails 2.3 to Rails 3 must be facing this one initial problem if you are using Mysql instead of sqlite3 which comes along with rails 3 gem.

rake db:migrate 
(in C:/Documents and Settings/mpenta/My Documents/Aptana Studio/demo)
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
126: The specified module could not be found. – C:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7.3-x86-mswin32/ext/
(See full trace by running task with—trace)

Rails 3 is a bit different, no doubt its more powerful and structured but things are a bit different here.
So lets first check u’ve made all installations :
Ruby 1.8.7 or above
Rails gem (rails 3)
Bundler gem (now that something new)
Yes bundler is something new and interesting – as they say “Bundler is the best way to manage your application dependencies ”.
What exactly bundler do ?
Bundler manages an application's dependencies through its entire life across many machines systematically and repeatedly.
For more information on use of bundler visit :

Steps for new Rails 3 app :
Step 1 : rails new app (for creating new app)
Step 2 : make required changes in config/database.yml file.
Example  for mysql :

# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
  adapter: mysql
  encoding: utf8
  database: temp_development
  username: root
  socket: /tmp/mysql.sock

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
  adapter: mysql
  encoding: utf8
  database: temp_test
  username: root
  socket: /tmp/mysql.sock

  adapter: mysql
  encoding: utf8
  database: temp_production
  username: root
  socket: /tmp/mysql.sock

Step 4 : Include “mysql” in gemfile
Step 5 : bundle install [appname]
A .bundle directory will be installed in you’re the root of you application.
All set to do rake db:create, and continue making your awesome rails 3 application.

No comments:

Post a Comment