Switching rails apps from sqlite to mysql
Since Rails 2.0.2, Sqlite has been the default database for new projects. This is great to get you started but at some stage you’re likely to want to move to a bigger DB like mysql or postgres. Here’s the steps involved:
Edit your config/database.yml file and make it look like this (change the database names, username and passwords to match your environment):
development:
adapter: mysql
encoding: utf8
database: myapp_development
username: root
password:
socket: /tmp/mysql.sock
test:
adapter: mysql
encoding: utf8
database: myapp_test
username: root
password:
socket: /tmp/mysql.sock
production:
adapter: mysql
encoding: utf8
database: myapp_production
username: root
password:
socket: /tmp/mysql.sock
Then, recreate your databases and tables:
$ rake db:create:all
$ rake db:migrate
That’s it!