How to use your own mysql database server with heroku?

后端 未结 3 1298
离开以前
离开以前 2021-02-09 15:19

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 c

相关标签:
3条回答
  • 2021-02-09 15:50

    According to the Heroku documentation, changing DATABASE_URL is the correct way to go.

    If you would like to have your rails application connect to a non-Heroku provided database, you can take advantage of this same mechanism. Simply set your DATABASE_URL config var to point to any cloud-accessible database, and Heroku will automatically create your database.yml file to point to your chosen server. The Amazon RDS Add-on does this for you automatically, though you can also use this same method to connect to non-RDS databases as well.

    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

    0 讨论(0)
  • 2021-02-09 16:00

    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

    0 讨论(0)
  • 2021-02-09 16:11

    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.

    0 讨论(0)
提交回复
热议问题