mysqldjangoamazon-ec2mysql-pythondjango-mysql

Is it possible to connect local django project to MySql running on AWS EC2? How?


What I tried:

{
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'dbtest',
        'USER': 'root',
        'HOST': '{IPv4 Public IP of the Instance}',
        'PASSWORD': 'password',
}

Now when I run python manage.py runserver it gives me the error

django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'xxx.xx.xxx.xxx' (using password: YES)")

Then I granted all privileges to this specific IP as well using: GRANT ALL PRIVILEGES ON *.* TO 'root'@'xxx.xx.xxx.xxx' WITH GRANT OPTION;

Still no luck.Same Error.


Solution

  • You also have to set MySQL configuration for allowing it to accept remote connection in mysqld.cnf file add change following value.

    [mysqld]
    bind-address    = 0.0.0.0
    # skip-networking
    

    then restart MySQL Service.

    and you also have to add Application port in Security Group of EC2 instance