简体   繁体   English

使用Mysql的Rails应用程序如何与heroku一起部署?

[英]Rails app using Mysql how to deploy with heroku?

How to deploy a Rails app using Mysql on heroku? 如何在Heroku上使用Mysql部署Rails应用程序?

I find out that my app did not need Amazon RDS (Too expensive for a small app). 我发现我的应用程序不需要Amazon RDS(对于小型应用程序来说太贵了)。

Here is my answer how to use Amazon RDS 这是我的答案,如何使用Amazon RDS

Heroku help deploying Rails app that uses Mysql database Heroku帮助部署使用Mysql数据库的Rails应用程序

Include mysql2 gem in your gemfile: 在您的gemfile中包含mysql2 gem:

gem 'mysql2'

Now, your choice can be: https://addons.heroku.com/cleardb add-ons. 现在,您可以选择: https : //addons.heroku.com/cleardb附加组件。 You can get upto 5mb free storage but you need to fill your credit card information for accessing it. 您可以获得5mb的免费存储空间,但需要填写信用卡信息才能访问它。

Steps for using clearDB add-ons are: 使用clearDB附加组件的步骤如下:

# add cleardb add-ons to your app
$ heroku addons:add cleardb:ignite
-----> Adding cleardb to sharp-mountain-4005... done, v18 (free)


# retrieve your database URL:
$ heroku config | grep CLEARDB_DATABASE_URL
CLEARDB_DATABASE_URL => mysql://adffdadf2341:adf4234@us-cdbr-east.cleardb.com/heroku_db?reconnect=true


# copy CLEARDB_DATABASE_URL config variable and set it to your DATABASE_URL config variable
$ heroku config:set DATABASE_URL='mysql://adffdadf2341:adf4234@us-cdbr-east.cleardb.com/heroku_db?reconnect=true'
Adding config vars:
DATABASE_URL => mysql2://adffd...b?reconnect=true
Restarting app... done, v61.

# NOTE: since we are using ```mysql2``` in our gemfile so replace mysql:// scheme in the CLEARDB_DATABASE_URL to mysql2://
$ heroku config:set DATABASE_URL='mysql2://adffdadf2341:adf4234@us-cdbr-east.cleardb.com/heroku_db?reconnect=true'
$ heroku config:set CLEARDB_DATABASE_URL='mysql2://adffdadf2341:adf4234@us-cdbr-east.cleardb.com/heroku_db?reconnect=true'

Please follow: https://devcenter.heroku.com/articles/cleardb for more information 请关注: https//devcenter.heroku.com/articles/cleardb了解更多信息

Hope that can help you. 希望能对您有所帮助。

If you do a heroku db:push from your MySql data, it'll automatically get pushed into the heorku PostgreSQL database structure. 如果您从MySql数据中执行heroku db:push ,它将自动推送到heorku PostgreSQL数据库结构中。

You can then do db:pulls and pull back into mysql. 然后,您可以执行db:pulls并拉回mysql。 Taps provides this database magic. Taps提供了这种数据库魔力。

It's really great -- I'd try it out first before trying to get RDS working. 真的很棒-在尝试使RDS工作之前,我会先尝试一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM