Search code examples
rubyheroku

How to use your own mysql database server with heroku?


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?


Solution

  • 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