Richard Stokes
Richard Stokes

Reputation: 3552

Rails 3.2 - Heroku deployment with remote MySQL database

Working on a rails app for my final year project, and I want to deploy it using heroku (with an obscure sub-domain for security) so that my supervisor can keep up to date with the latest developments. Instead of the default sqlite database, my rails app connects to a remote MySQL database with pre-existing schema/data. I have my database.yml set up fine, as when I run my app locally, it connects to the remote db and works fine. However, when I push it to heroku, the home page won't even open.

I assume Heroku, by default, looks for your database (PostGreSQL, if I'm correct) locally. How do I configure my app so that Heroku can connect to my remote db? And if this is not possible with Heroku, are there any other easy and (most importantly) free Rails hosting service out there that anyone could recommend?

Upvotes: 2

Views: 1259

Answers (1)

lstoll
lstoll

Reputation: 179

Heroku overwrite the database.yml with a version that reads from the DATABASE_URL config parameter. You can set this to point to your remote MySQL server with something like:

$ heroku config:add DATABASE_URL=mysql2://username:password@host:port/database

That will use the mysql2 adapter to connect to your DB.

Upvotes: 8

Related Questions