Django的+ MySQL的弹性魔豆 - 错误当查询的MySQL [英] Django + MySQL on Elastic Beanstalk - Error When Querying MySQL

查看:176
本文介绍了Django的+ MySQL的弹性魔豆 - 错误当查询的MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一个错误,当我查询MySQL的托管弹性魔豆我的Django应用程序。错误说:

I'm getting an error when I query MySQL on my Django app hosted on elastic beanstalk. The error says:

OperationalError在/管理/登入 (1045,拒绝访问用户adminDB'@'172.30.23.5'(使用密码:YES))

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

下面是我的config文件:

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/"

下面是我的数据库节settings.py:

Here is my the databases section on settings.py:

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'],
        }
    }

我创建通过 EB创建命令EB环境,继而又在其网站上EB控制台上创建RDS数据库。还有什么我需要做的Django连接到MySQL?是与安全组什么的?

I created the eb environment through the eb create command and then proceeded to create an RDS database on the eb console on their website. Is there anything else I need to do to connect Django to MySQL? Something to do with security groups or something?

谢谢!

推荐答案

感谢您的答复@DrewPierce,但问题是一个简单的,而且它也是非常愚蠢的。原来,美元符号在我的RDS的密码是造成问题。它改变了一个简单的密码,我成功地登录。

Thanks for your response @DrewPierce, but the problem was a simple one, and it's also extremely silly. Turns out the dollar sign in my RDS password was causing a problem. Changed it to a simpler password and I successfully logged in.

希望这有助于任何人有类似的问题!

Hope this helps anyone else with a similar issue!

这篇关于Django的+ MySQL的弹性魔豆 - 错误当查询的MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆