How to use your own mysql database server with heroku?

后端 未结 3 1306
离开以前
离开以前 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条回答
  •  猫巷女王i
    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

提交回复
热议问题