Django + MySQL on elastic beanstalk - error when querying MySQL

I am getting an error when querying MySQL in a Django application hosted on an elastic beanstalk. The error says:

OperationalError at / admin / login (1045, "Access denied for user" adminDB'@'172.30.23.5 '(using password: YES) ")

Here is my .config file:

container_commands:
  01_migrate:
    command: "source /opt/python/run/venv/bin/activate && python manage.py migrate --noinput"
    leader_only: true

option_settings:
  "aws:elasticbeanstalk:application:environment":
    DJANGO_SETTINGS_MODULE: "mysite.settings"
    "PYTHONPATH": "/opt/python/current/app/mysite:$PYTHONPATH"
    "ALLOWED_HOSTS": ".elasticbeanstalk.com"
  "aws:elasticbeanstalk:container:python":
    WSGIPath: mysite/wsgi.py
    NumProcesses: 3
    NumThreads: 20
  "aws:elasticbeanstalk:container:python:staticfiles":
    "/static/": "www/static/"

      

Here is my settings.py database section:

DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': os.environ['RDS_DB_NAME'],
            'USER': os.environ['RDS_USERNAME'],
            'PASSWORD': os.environ['RDS_PASSWORD'],
            'HOST': os.environ['RDS_HOSTNAME'],
            'PORT': os.environ['RDS_PORT'],
        }
    }

      

I created an eb environment using the command eb create

and then proceeded to create an RDS database in the eb console on my website. Is there something else I need to do in order to connect Django to MySQL? Something to do with security groups or something?

Thank!

+4


source to share


1 answer


Thanks for your answer @DrewPierce, but the problem was simple and that is also extremely silly. It turns out the dollar sign in my RDS password is causing the problem. Changed it to a simpler password and I logged in successfully.



Hope this helps someone else with a similar problem!

+2


source







All Articles