How to setup mysql database.yml in Ubuntu ?

Steps which I am sharing with you has worked for me and I hope that would help you in connecting your mysql database to your ruby on rails application.

Step 1. Open terminal and execute this command : sudo apt-get install mysql-server libmysqlclient-dev libmysql-ruby

Step2. Change Directory to your application folder ,like cd /rails_projects/cg

Step3. Now ,install mysql gem : sudo gem install mysql

Step4. Configure your database.yml :  sudo gedit configure/database.yml

Step5.Paste this code:
development:
  adapter: mysql
  encoding: utf8
  database: yourdatabase_development
  pool: 5
  username: root
  password: yourpassword


test:
  adapter: mysql
  encoding: utf8
  database: yourdatabase_test
  pool: 5
  username: root
  password: yourpassword



production:
  adapter: mysql
  encoding: utf8
  database: yourdatabase_production
  pool: 5
  username: root
  password: yourpasswod


Done! Now create database using rake:db create  and enjoy!

No comments:

Post a Comment