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:
- 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.
- 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: configuration, MySQL, rails 2.0, Rails on Windows Posted in


December 22nd, 2008 at 12:16 am
[...] recorded first by YamiValentine on 2008-12-10→ MySQL Configuration for Rails [...]
May 5th, 2009 at 3:30 am
Thanks great stuff