Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

I've started working with django, and here is the error on 'runserver' after setting up 'DATABASES' in settings.py

mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)") 

My settings.py portion of code:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'my_site',                      # Or path to database file if using sqlite3.
        'USER': 'root',                      # Not used with sqlite3.
        'PASSWORD': 'root',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }

}

I've created 'my_site' database and privileges are set in the right way (root has all privileges). I've done this operations with 'phpmyadmin'.

What goes wrong?

like image 573
Massimo Variolo Avatar asked Apr 16 '12 20:04

Massimo Variolo


People also ask

How do I fix error 1045?

The #1045 error is a phpMyAdmin authentication error that can be caused by an incorrectly typed username or password. To troubleshoot this error, you should complete a password reset and make sure you're using the correct database host name.

What is Error 1045 28000 Access denied?

MySQL users often face an issue called Error 1045 (28000) access denied for user 'root'@'localhost' (using password: yes). This usually occurs when you enter an incorrect password or password for your database. Fixing these credentials can resolve this error in no time.


1 Answers

Run in console

mysql> grant all privileges on *.* to root@localhost identified by 'password' with grant option;
like image 79
Akhilraj N S Avatar answered Oct 06 '22 17:10

Akhilraj N S