djangolocalhostsyncdb

Django syncdb mysql error on localhost -> (1045, "Access denied for user 'ODBC'@'localhost')


Hoping someone can help me connect django to mysql db on localhost...

I have installed Django site into virtualenv folder on my desktop and following django docs Tutorial step by step.

I have mysqlclient installed via pip as per django docs.

I have WAMP V2.5 with latest phpmyadmin installed and operational.

The Django test site loads with localhost:8000 and I can easily setup a site with sqli.

Within localhost/phpmyadmin I created a blank database named 'test_db' and as an example for this question I used username = 'user' and password = 'pwd'.

My settings.py file is setup as below for the database settings:

DATABASES = {
    'default': 'django.db.backends.mysql',
    'NAME': 'test_db',
    'HOST': 'localhost',
    'PORT': '3306',
    'USERNAME': 'user',
    'PASSWORD': 'pwd',
    }
}

Once I save the settings.py script, I run the command:

python manage.py syncdb

The result I get is:

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

I can change the username and password to the root user and password and I still get the same result.

I have spent days on this Googling and Youtubing but nothing has helped so far... Any help appreciated.


Solution

  • Change your Database settings:

    'ENGINE':'django.db.backends.mysql',  
    'NAME': 'test_db',  
    'USER': 'root',  
    'PASSWORD': '',  
    'HOST': 'localhost',  
    'PORT': '3306',