About ruby on rails, hackintosh, iphone3g and etc.

Friday, January 30, 2009

Moving Rails to Production Database

After development (better during development) of rails application, it is good to move/try out the production database environment. To move to production database (e.g. from sqlite to mysql), firstly need to modify the database.yml file in /config directory of rails app.

database.yml

production:
adapter: mysql
database:
username: root
password:
socket: /path/to/your/mysql.sock

Change the database name to your database name. For mysql, create a schema that match the schema name. Enter the username and password, try to avoid root. 

In mysql terminal, create a dababase schema using this command:

mysqladmin -u root -p create

Create a user for this schema and use the username. Leave socket field as it is.

Save database.yml and execute the command below:

rake db:schema:load RAILS_ENV=production

There maybe error if mysql gem plugin is not installed, this can be resolved by this command:

gem install mysql

References:

No comments: