在heroku上使用远程mysql Connect To Remote MySQL Database From Heroku

0.
bundle install --without devlopment, test, doc
bundle update
bundle install
git add .
git commit -m ""
git push -u origin master

1. $heroku login
2. $heroku create
3. $git push heroku master

4.0 add credit card information on heroku.com
4.1 $heroku addons:add cleardb:ignite
4.2 $heroku config

5. $heroku addons

== Resources for appname
Plan                         Name                 Price
---------------------------  -------------------  -----
cleardb:ignite               budding-freely-9331  free
heroku-postgresql:hobby-dev  flying-calmly-8591   free

=== Attachments for appname
Name              Add-on               Billing App
----------------  -------------------  ---------------
CLEARDB_DATABASE  budding-freely-9331  appname
DATABASE          flying-calmly-8591   appname


6. heroku addons:destroy flying-calmly-8591 --confirm appname
6.1 $heroku config

--
CLEARDB_DATABASE_URL: mysql://[email protected]/...reconnect=true
LANG:                 en_US.UTF-8
RACK_ENV:             production
RAILS_ENV:            production
--

7. $heroku config:set DATABASE_URL=mysql2://username:password@hostip:3306/dbname
CLEARDB_DATABASE_URL: mysql://...
DATABASE_URL:mysql2://...

8. $heroku config:add TZ=Asia/Tokyo (optional)
8.1 $heroku config:add LANG=ja_JP.UTF-8 (optional)

9. 好像如果在deploy以前运行了以下命令,在步骤8后就可以直接运行步骤10。如果不运行这两个命令,在8以后 heroku run rake db:create 或者migrate都报错。说mysql2没有load,但是在Gemfile有,原因不明
$rake db:create RAILS_ENV=production
$rake db:migrate RAILS_ENV=production

9.1 $heroku run rake db:migrate

10. $heroku open

你可能感兴趣的:(Mysql,Linux/Unix)