Ruby on Rails and Databases

Ruby on Rails works with popular and esoteric databases.

Here's a short list:

  • SQLite
  • MySQL
  • MongoDB
  • Redis
  • CouchDB


How to setup MySQL with RoR:

First. let's install: mysql-devel:

sudo yum install mysql-devel

Install the gem:

gem install mysql2

Let's add the gem to the Gemfile

#gem mysql
gem 'mysql2'


Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.15
Parsing documentation for mysql2-0.3.15
Installing ri documentation for mysql2-0.3.15
Done installing documentation for mysql2 after 0 seconds
1 gem installed


To add a table column, run this command:

rails generate migration add_COLUMN_NAME_to_TABLENAME COLUMN_NAME:TYPE


rails generate migration add_name_to_pet name:string