Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

522
Views
Using remote MySQL database on Heroku running Django app

I've been struggling with the following problem: I have a MySQL database running on a remote web host. I connect to the MySQL database in my Django app (I use it as the main database). The Django app is running on a Heroku server but I get different data results compared to running it locally.

Am I missing something, or are changes done on Heroku not committed to the database?

MySQL settings:

DATABASES = {
 #   'default': {
  #      'ENGINE': 'django.db.backends.sqlite3',
   #     'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
   # }
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'xxx',
        'USER': 'xxx',
        'PASSWORD': 'xxx',
        'HOST': 'xxx',
        'PORT': 'xxx',
    }
}
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I just see that if you delete the ad-on provided by heroku, it will use the DB you put on the settings of your project

over 4 years ago · Santiago Trujillo Report

0

I believe Juan Carlos Hernández is correct. To expand on his answer, Heroku uses it's own database instance, unless you tell it otherwise by pointing the DATABASE_URL to the one you would like to use. Please note that Heroku will prevent you from overwriting the DATABASE_URL in use since that will destroy the existing database. Although tagged as ruby-on-rails, the answers I found here seem relevant.

To summarize, you just have to run

heroku config:add DATABASE_URL=mysql://dbusername:dbpassword@databasehostIP:3306/databasename
heroku config:add SHARED_DATABASE_URL=mysql://dbusername:dbpassword@databasehostIP:3306/databasename

Then do

heroku restart

Or you can change these variables in the Heroku panel.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!