How to use custom mysql database server with hero?

I want to use the mysql database, which is hosted on my own server. I changed the DATABASE_URL and SHARED_DATABASE_URL config parameters to point to my server, but it is still trying to connect to heroku amazonaws servers. How to fix it?

+6
ruby heroku
source share
3 answers

According to Heroku documentation , changing DATABASE_URL is the right way.

If you want your rails application to connect to a non-Heroku database, you can use the same mechanism. Just set DATABASE_URL config var to any cloud database, and Heroku will automatically create a database.yml file to point to your selected server. The Amazon RDS add-in does this automatically for you, although you can also use the same method to connect to databases other than RDS.

Here is an example that should work:

heroku config:add DATABASE_URL=mysql://user: password@host /db

You may need to redistribute by making changes and doing git push heroku master

+10
source share

By the way, the host is XXXX.amazonaws.com, where XXX is a long host that is likely to change. If you can add a wildcard, then the simplest %.amazonaws.com

+3
source share

I had the same problem with my Dreamhost MySQL database. Turns out the solution was to say that Dreamhost was ok to accept connections from this foreign host. Otherwise, Dreamhost blocks all requests to MySQL that do not come from their systems.

It seems that if Heroku returns to Amazon AWS despite your DATABASE_URL, it is because he is denied access to your MySQL database.

0
source share

All Articles