views:

3803

answers:

8

I want to create my Rails application with MySQL, because I like it so much. How can I do that in the latest version of Rails?

+18  A: 

Normally, you would create a new Rails app using

rails ProjectName

To use MySQL, use

rails -d mysql ProjectName
Daniel Broekman
+2  A: 

If you are creating a new rails application you can set the database using the -d switch like this:

rails -d mysql myapp

Its always easy to switch your database later though, and using sqlite really is easier if you are developing on a Mac.

James Avery
+13  A: 

If you already have a rails project, change the adapter in the config/database.yml file to mysql and make sure you specify a valid username and password, and optionally, a socket:

development:
  adapter: mysql
  database: db_name_dev
  username: koploper
  password:
  host: localhost
  socket: /tmp/mysql.sock
Michiel de Mare
A: 

I installed rails 2.0 a couple of days ago in my ubuntu server and it chose mysql as default.

A: 

giancarlo -- remember this Q&A when you upgrade from Rails 2.0 to Rails 2.0.2 -- that was the version where SQLite became the default database for a new application instead of MySQL.

Plus, if you don't have a compelling reason to use version 2.0, I'd recommended version 2.1. It's been out since June, is stable, and of course has nice new features. Time zone support and named scopes are my favorites.

slothbear
A: 

para usar o mysql por padrao o "d" é em maiusculo rails -D mysql 'project_name'

+3  A: 
rails -d mysql ProjectName
huacnlee
A: 

Rails wiki always good for the very first layer configuration information.

http://newwiki.rubyonrails.org/database-support/mysql

riva
rails wiki is unmaintained and outdated
knoopx