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

Created at 17-Feb-2023 , By samar

The error message you're encountering, "django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")", indicates that there is a problem with the database credentials you have provided in your Django settings. The error message is saying that the user 'root' with host 'localhost' is being denied access to the database because a password has not been provided.

To resolve this issue, you will need to provide the correct database credentials in your Django settings.


    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'databasename',
        'HOST': '',
        'PORT': '3306',
        'USER': 'root',
        'PASSWORD': 'password',

In the above code, the database engine used is MySQL, and the database is given the name 'databasename'. The host address of the database is specified as '' and the port number is specified as '3306'. The user accessing the database is given the username 'root' and the password for the database user (root) is 'password'.

In Django, the default database host is 'localhost' or and the default database port is '5432' for PostgreSQL, '3306' for MySQL, and '27017' for MongoDB.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.