クライアントDB接続のための設定

1. WEB_APP_ROOT/config/database.ymlを修正(host(DBサーバー)は環境に応じて修正)

 development:
  adapter: mysql
  database: shohu_development
  username: shohu
  password:
  host: localhost
  encoding: utf8

 test:
  adapter: mysql
  database: shohu_test
  username: shohu
  password:
  host: localhost
  encoding: utf8

 production:
  adapter: mysql
  database: shohu_production
  username: shohu
  password:
  host: localhost
  encoding: utf8
DBサーバー側設定
 # mysql -u root -p
 DB作成
 >create database shohu_test;
 >create database shohu_development;
 >create database shohu_production;
 ユーザー作成
 >grant all on shohu_test.* to shohu@localhost;
 >grant all on shohu_development.* to shohu@localhost;
 >grant all on shohu_production.* to shohu@localhost;
 外部からのアクセス許可
 >grant all on shohu_test.* to shohu@'192.168.1.0/255.255.255.0';
 >grant all on shohu_development.* to shohu@'192.168.1.0/255.255.255.0';
 >grant all on shohu_production.* to shohu@'192.168.1.0/255.255.255.0';

アプリの準備

初期設定

shohu_yyyymmdd.zip を /home/shohu/project配下にアップロード

 tar unzip shohu_yyyymmdd.zip
 cd shohu/config
 vi database.yml
 -----
 host:localhost ← 値をlocalhostに変更。3箇所
 -----
Migrate

テーブル構築

 cd /home/shohu/project/shohu
 rake db:migrate VERSION=0
 rake db:migrate VERSION=1
 rake db:migrate VERSION=2