如何将自己的mysql数据库服务器与heroku一起使用?
我想使用托管在我自己的服务器上的 mysql 数据库。 我已更改 DATABASE_URL 和 SHARED_DATABASE_URL 配置变量以指向我的服务器,但它仍在尝试连接到 heroku 的 amazonaws 服务器。我该如何解决这个问题?
I want to use mysql database which is hosted on my own server.
I've changed DATABASE_URL and SHARED_DATABASE_URL config vars to point to my server, but it's still trying to connect to heroku's amazonaws servers. How do I fix that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据 Heroku 文档,更改
DATABASE_URL
是正确的方法。下面是一个应该有效的示例:
heroku config:add DATABASE_URL=mysql://user:password@host/db
您可能需要通过进行更改并运行
git push heroku master<来重新部署/代码>
According to the Heroku documentation, changing
DATABASE_URL
is the correct way to go.Here's an example that should work:
heroku config:add DATABASE_URL=mysql://user:password@host/db
You may need to redeploy by making a change and running
git push heroku master
顺便说一下,主机是 XXXX.amazonaws.com,其中 XXX 是很长的主机名,可能会发生变化。如果您可以添加通配符,这是最简单的
%.amazonaws.com
By the way, the host is XXXX.amazonaws.com, where XXX is a long host hame that probably changes. If you can add a wildcard, that's the easiest
%.amazonaws.com
我的 Dreamhost MySQL 数据库也遇到了同样的问题。结果解决方案是告诉 Dreamhost 可以接受来自该外部主机的连接。否则,Dreamhost 会阻止所有非源自其系统的对 MySQL 的请求。
看起来,如果 Heroku 不管您的 DATABASE_URL 是否都回退到 Amazon AWS,那是因为它被拒绝访问您的 MySQL 数据库。
I had this exact same problem with my Dreamhost MySQL database. Turns out the solution was to tell Dreamhost is was Ok to accept connections from this foreign host. Otherwise, Dreamhost blocks all requests to MySQL that don't originate from their systems.
It seems that if Heroku is falling back to Amazon AWS despite your DATABASE_URL, it's because it's being denied access to your MySQL database.