Setting mysql database for rails

You have to install mysql or mysql2 gem using following commands:

$ gem install mysql2

Add following code in Gemfile:

gem 'mysql2'

Then install bundle using following command:

$ bundle install

And set config/database.yml file as follows:

development:
adapter: mysql2
database: sblog_development
username: root
password: root_password
host: 127.0.0.1

test:
adapter: mysql2
database: sblog_test
username: root
password: root_password
host: 127.0.0.1

production:
adapter: mysql2
database: sblog_production
username: root
password: root_password
host: 127.0.0.1

Create databse using following commands

$ rake db:create

And migrate database using following commands

$ rake db:migrate

Enjoy with Rails. Happy coding…

2 thoughts on “Setting mysql database for rails

  1. I found your website through a random stroke of luck. It helped me do my research on this topic. I have spent lots of time looking through your site. You have something good going here, keep it up!

  2. Pingback: Use Both MongoDB and MySql database in rails Application | Ganesh Kunwar

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s