skip to Main Content

I have come accross a strange issue, I have deployed a django site to an Ubuntu 20.04 LTS server. The problem is my django app can not connect to the database because It is doesn’t using the db connection credentials that have identified in app settings.py. It is using root with no password. But when I can run manage.py db operations without any problem.

This is my settings.py

    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'pplus_db',
        'USER': 'pplus_user',
        'PASSWORD': 'dfa@4GL-5qQU',
        'HOST': 'localhost', 
        'PORT':'3306',
    }
}

The Error:

OperationalError at /accounts/login/
(1045, "Access denied for user 'root'@'localhost' (using password: NO)")
Request Method: POST
Request URL:    http://IP_ADDRESS/accounts/login/
Django Version: 3.2.5
Exception Type: OperationalError
Exception Value:    
(1045, "Access denied for user 'root'@'localhost' (using password: NO)")

2

Answers


  1. Chosen as BEST ANSWER

    I have managed to solve the problem, I think the issue was in cashing. After follow this solution django.db.utils.OperationalError: (1045:Access denied for user 'root'@'localhost' (using password: NO)

    Make sure to restart your services:
    sudo systemctl daemon-reload
    sudo systemctl restart gunicorn
    Or if you can restart the server.


  2. you just need to run
    sudo mysqld_safe --skip-grant-tables

    or reset your MySQL password to null

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search