码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2015-07-14 22:39:40      阅读:480      评论:0      收藏:0      [点我收藏+]

标签:

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://...@us-cdbr-iron-east-02.cleardb.net/...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

版权声明:本文为博主原创文章,未经博主允许不得转载。

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

标签:

原文地址:http://blog.csdn.net/pyang1989/article/details/46883747

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!