MySQL Configuration for Rails


As of Rails 2.0, when you use the rails command to generate a new project, the database.yml file in the configuration folder defaults to using SQLite instead of MySQL.

I still advocate using MySQL. Although it is more “heavyweight” to install (unless you’re using InstantRails on Windows, which installs everything quite easily), it has a few advantages over SQLite:

  1. Tools: MySQL has a rich set of GUI tools available to maintain your databases–everything from user and database administrator to a query browser. These make life much, much easier.
  2. Features: SQLite, since it aims to be lightweight, ignores certain features, such as renaming columns. This might mean that–if you don’t use migrations–you’ll run into these issues at times.

Really, it’s a matter of personal choice; but if you choose to use MySQL, you might find it annoying to try and find a sample configuration file that you can use! For convenience, here’s a sample (generated in a Rails 1.2 project):

development:
adapter: mysql
database: railsrocket_development
encoding: utf8
username: dev
password: dev
host: localhost

test:
adapter: mysql
database: railsrocket_test
encoding: utf8
username: dev
password: dev
host: localhost

production:
adapter: mysql
database: railsrocket_production
encoding: utf8
username: enterUserName
password: enterPassword
host: localhost

Aside from needing to enter your production-mode username and password, the only real change is using the UTF-8 encoding. (It makes life a little easier if you have a multilingual application.)

Tags: , , ,     Posted in Deployment, Development

Rate this article:
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Related Content


2 Responses to “MySQL Configuration for Rails”

  1. Recent URLs tagged Databases - Urlrecorder Says:

    [...] recorded first by YamiValentine on 2008-12-10→ MySQL Configuration for Rails [...]

  2. The YPI Says:

    Thanks great stuff

Leave a Reply