Can I use mysql database from my personal web server instead of heroku's database?
I configured my production database like this:
production: adapter: mysql2 database: somedatabase username: someusername password: somepassword host: 1.1.1.1:1234
But, this doesn't work, my app still uses heroku's shared database.
Existing ClearDB shared MySQL customers can now run heroku addons:upgrade to upgrade existing ClearDB shared MySQL add-ons to dedicated ClearDB MySQL add-ons.
Starting at $0/mo.
We have deployed a PHP project to Heroku, made a remote MySQL database, configured the database using PHPMyAdmin, and finally connected our app to the database.
This is old but in case anyone drops around looking for an answer, it's much easier than using the gem. Just provide a DATABASE_URL
and SHARED_DATABASE_URL
(not sure if the second is needed). The database url format is adapter://username:password@hostname:port/database
, so for example, you would do:
heroku config:add DATABASE_URL=mysql://etok:somepassword@<your-server>:3306/etok heroku config:add SHARED_DATABASE_URL=mysql://etok:[email protected]:3306/etok
Then re-deploy your app. It will read your DATABASE_URL
and generate the database.yml from that. The default port is already 3306 so it's not needed in the url in your case. When you deploy, you may notice that it generates your database.yml:
-----> Writing config/database.yml to read from DATABASE_URL
Then you're set (as long as your server accepts connections from your heroku host.
I've written a gem that may help with this. You can find it at:
http://github.com/nbudin/heroku_external_db
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With