How to connect project's ruby on rails with mysql server.


Posted on 2015-01-08 04:11:18


Then I have installed ruby on rails and run demo application connect with mysql. I have experiences for it. I will share its to guys.
1. You created a new project with ROR. 2. You need check column gem 'mysql2' of gemfile file in folder project. If you don't see it, you can add that column to gemfile file. 3. Run command line "bundle update" which will install all package of gem from site https://rubygems.org 4. In file /config/database.yml, you can config
development:
 adapter: mysql2
 encoding: utf8
 database: railstest
 pool: 5
 username: account_of_you_to_access_mysql
 password: password_of_you_to_access_mysql
 socket: /var/run/mysqld/mysqld.sock
 host: localhost
5. Run command line rake db:create --trace. It will read from file database.yml then create database railstest in your mysql. 6. Restart server. 7. Open browser then run localhost:3000.
I hope this tutorial helps. You can like page and share if you like. Thank you.