阅读背景:

django无法在aws上连接mysql服务器

来源:互联网 

my django version is 2.0.1, i would like to connect with mysql. Database which is located on a amzon ec2

我的django版本是2.0.1,我想连接到mysql。位于amzon上的数据库

I get this error when I'm running the Django server :

当我运行Django服务器时,会得到这个错误:

this is my settings.py DATABASES = {

这是我的设置。py数据库= {

    'default': {
        'ENGINE': 'django.db.backends.mysql', 
        'NAME': 'graph',
        'USER': 'root',
        'PASSWORD': 'password',
        'HOST': 'hostname',   # Or an IP Address that your DB is hosted on
        'PORT': '3306',
    }
}

1 个解决方案

#1


1  

You have to check few things in your infra as well as MySQL configuration.

您必须检查您的infra和MySQL配置中的一些东西。

  • Check your security group & NACL that mysql port is open on your mysql ec2 server.

    检查您的安全组& NACL是否在mysql ec2服务器上打开了mysql端口。

  • Did you allow remote connection in MySQL? if not then use below query to allow remote connection from publicly.

    你在MySQL中允许远程连接吗?如果没有,则使用下面的查询来允许远程连接公开。

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

授予*的所有特权。*以“密码”识别的“root”@“%”,并提供授予选项;

FLUSH PRIVILEGES;

冲洗特权;

Feel free to comment if both points are configured properly.

如果两个点配置正确,请随意评论。


分享到: