如何将本地MySQL数据库部署到Heroku [英] How to deploy local MySQL database to Heroku

查看:516
本文介绍了如何将本地MySQL数据库部署到Heroku的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用Heroku的新手,我有一个Ruby / Sinatra应用程序,我计划使用MySQL数据库作为主数据存储。 然而,我不想将结果直接写到Heroku上的数据库中。相反,我想将结果写入本地数据库,然后能够轻松地将本地数据库部署/更新/复制到Heroku上的生产数据库。



我该如何做这件事?



谢谢。

解决方案

Heroku本身使用postgres。如果你在本地使用,生活会更容易。



您可以从heroku导入/导出postgres转储文件,如下所述: https://devcenter.heroku.com/articles/heroku-postgres-import-export



如果你真的想使用mysql,你需要遵循两条路径。

1)在本地运行mysql,但转换为postgres当使用mysql2psql gem迁移到Heroku时,如下所述: https://devcenter.heroku.com/ articles / heroku-mysql

2)使用一个mysql插件,如 https://addons.heroku.com/cleardb



然而我的建议是使用postgres,因为它是烘焙的进入Heroku,你将使用Heroku的默认方式,而不是与他们对抗。



Postgres也非常好!


I'm new to using Heroku and I have a Ruby/Sinatra app in which I plan on using a MySQL database as the main data store.

However, I do not want to write results directly to the database on Heroku. Instead, I want to write the results to a local database, and then be able to easily deploy/update/copy my local DB to the "production" database on Heroku.

How do I do this?

Thanks.

解决方案

Firstly Heroku natively uses postgres. Life will be easier for you if you use that locally.

You can import / export postgres dump files from heroku as described here: https://devcenter.heroku.com/articles/heroku-postgres-import-export

If you really want to use mysql, you have two paths to follow.

1) Run mysql locally, but convert to postgres when migrating to Heroku using the mysql2psql gem, as described here: https://devcenter.heroku.com/articles/heroku-mysql

2) Use a mysql addon like https://addons.heroku.com/cleardb

However my recommendation would be to use postgres end to end, as it is baked into Heroku, and you'll be working with the default ways of using Heroku, not against them.

Postgres is very good too!

这篇关于如何将本地MySQL数据库部署到Heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆