Nithish Albin
Nithish Albin

Reputation: 362

django unable to connect mysql server on aws

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

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

this is my settings.py DATABASES = {

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

Upvotes: 1

Views: 1203

Answers (1)

Saurabh Srivastava
Saurabh Srivastava

Reputation: 185

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

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

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

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

FLUSH PRIVILEGES;

Feel free to comment if both points are configured properly.

Upvotes: 1

Related Questions