Search code examples
djangolinuxpython-3.6mysql-8.0mysql-error-1045

django:mysql:error(1045, "Access denied for user 'root'@'localhost' (using password: NO)")


I am a newbie, just getting into Django, I want to implement django and mysql connections,and i built django1.11.17 and mysql8.0 in linux environment.

When I type command

python3 manage.py makemigrations 

Then give an error

MySQLdb._exceptions.OperationalError: (1045, "Access denied for user 'django1'@'localhost' (using password: NO)")

I read a lot of questions about this error on the forum, all said that it is an account and password problem, so,I created a database Firstproject, then created a new user Django1, granted all privileges on Firstproject.* to django1@%, and flushed privileges. but after I set the account permissions, this problem still occurs.

Setting.py about mysql configuration

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME':'Firstproject',
        'USER':'django1',
        'PASSSWORD':'asdewq',
        'HOST':'localhost',
        'PORT':'3306'
    }
}

More details about the error

Traceback (most recent call last):
  File "/home/ccheng/.local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
    self.connect()
  File "/home/ccheng/.local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 189, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/home/ccheng/.local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 274, in get_new_connection
    conn = Database.connect(**conn_params)
  File "/home/ccheng/.local/lib/python3.6/site-packages/MySQLdb/__init__.py", line 84, in Connect
    return Connection(*args, **kwargs)
  File "/home/ccheng/.local/lib/python3.6/site-packages/MySQLdb/connections.py", line 164, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (1045, "Access denied for user 'django1'@'localhost' (using password: NO)")

Can someone point me where I am wrong?


Solution

  • The word "PASSSWORD" is not spelled correctly.