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?
views:
3803answers:
8Normally, you would create a new Rails app using
rails ProjectName
To use MySQL, use
rails -d mysql ProjectName
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.
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
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.
Rails wiki always good for the very first layer configuration information.