我是 Heroku 的新手,我有一个 Ruby/Sinatra 应用程序,我计划在其中使用 MySQL 数据库作为主要数据存储.
但是,我不想将结果直接写入 Heroku 上的数据库.相反,我想将结果写入本地数据库,然后能够轻松地将我的本地数据库部署/更新/复制到 Heroku 上的生产"数据库.
我该怎么做?
谢谢.
首先 Heroku 原生使用 postgres.如果您在本地使用它,您的生活会更轻松.
您可以按照此处所述从 heroku 导入/导出 postgres 转储文件:https://devcenter.heroku.com/articles/heroku-postgres-import-export
如果你真的想用mysql,你有两条路可以走.
1) 在本地运行 mysql,但在使用 mysql2psql gem 迁移到 Heroku 时转换为 postgres,如下所述:https://devcenter.heroku.com/articles/heroku-mysql
2) 使用像 https://addons.heroku.com/cleardb 的 mysql 插件>
不过,我的建议是端到端使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!