0

I am new to Django.i am learning Django for the past few weeks,i have some trouble on changing the databse to sqllite to mysql.

setting.py

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.mysql',
    'NAME': 'mydb',
    'USER': 'root',
    'PASSWORD': ' ',
    'HOST': 'localhost',
    'PORT': '3306',
}}

When i try to run the server using py manage.py runserver

It show me the error like

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

SPECIFICATION

  • python-3.8
  • django-3
  • MySQL(xampp)
  • OS-windows
Venkat Cpr
  • 153
  • 1
  • 11

1 Answers1

0

This is most likely an issue with your USER, PASSWORD or HOST fields. You are probably not providing correct values. Try executing mysql -u root -p -h localhost and enter the password when asked for it. You should get the same error.

My guess is your password is just empty. So delete the space character for password and it should work.

If that is the case, you should really set a password. Refer to this - How to reset or change the MySQL root password?

Sanil Khurana
  • 1,129
  • 9
  • 20