简体   繁体   中英

django.db.utils.OperationalError: (1045, u“Access denied for user 'my_user'@'localhost' (using password: NO)”)

I am trying to connect to MySQL from DJango. My settings.py file:

DATABASES = {
          'default':{
             'ENGINE': 'django.db.backends.mysql',
             'Name': 'my_db',
             'User': 'my_user',
             'Password': 'my_pass',
             'Host': 'localhost',
             'Port': '3306'
          }
}

}

I am getting following error.

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

I have tried following steps to solve the problem.

I have created the user:

    create user 'my_user'@'localhost' identified by 'my_pass';

And granted access as follows:

    grant all on *.* to 'my_user'@'localhost';
    flush privileges;

But, even though my problem not yet fixed. Can someone help me?

Thanks.

All the database config variables need to be caps but you have provided in title case.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM