简体   繁体   English

Django(1045,“用户'root'@'localhost'的访问被拒绝(使用密码:NO)”)

[英]Django (1045, "Access denied for user 'root'@'localhost' (using password: NO)")

I have come accross a strange issue, I have deployed a django site to an Ubuntu 20.04 LTS server.我遇到了一个奇怪的问题,我已将 django 站点部署到 Ubuntu 20.04 LTS 服务器。 The problem is my django app can not connect to the database because It is doesn't using the db connection credentials that have identified in app settings.py.问题是我的 django 应用程序无法连接到数据库,因为它没有使用在 app settings.py 中标识的数据库连接凭据。 It is using root with no password.它使用没有密码的root。 But when I can run manage.py db operations without any problem.但是当我可以毫无问题地运行 manage.py db 操作时。

This is my settings.py这是我的settings.py

    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'pplus_db',
        'USER': 'pplus_user',
        'PASSWORD': 'dfa@4GL-5qQU',
        'HOST': 'localhost', 
        'PORT':'3306',
    }
}

The Error:错误:

OperationalError at /accounts/login/
(1045, "Access denied for user 'root'@'localhost' (using password: NO)")
Request Method: POST
Request URL:    http://IP_ADDRESS/accounts/login/
Django Version: 3.2.5
Exception Type: OperationalError
Exception Value:    
(1045, "Access denied for user 'root'@'localhost' (using password: NO)")

I have managed to solve the problem, I think the issue was in cashing.我已经设法解决了这个问题,我认为问题出在兑现上。 After follow this solution django.db.utils.OperationalError: (1045:Access denied for user 'root'@'localhost' (using password: NO)按照此解决方案后django.db.utils.OperationalError: (1045:Access denied for user 'root'@'localhost' (using password: NO)

Make sure to restart your services:确保重新启动您的服务:
sudo systemctl daemon-reload须藤 systemctl 守护进程重新加载
sudo systemctl restart gunicorn须藤 systemctl 重启 gunicorn
Or if you can restart the server.或者,如果您可以重新启动服务器。

you just need to run sudo mysqld_safe --skip-grant-tables你只需要运行sudo mysqld_safe --skip-grant-tables

or reset your MySQL password to null或将您的 MySQL 密码重置为 null

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OperationalError:(1045,“拒绝用户'root'@'localhost'的访问(使用密码:是)”) - OperationalError: (1045, “Access denied for user 'root'@'localhost' (using password: YES)”) 错误1045(28000):用户'= root'@'localhost'的访问被拒绝(使用密码:否) - ERROR 1045 (28000): Access denied for user '=root'@'localhost' (using password: NO) LAMP#1045-用户'root'@'localhost'的访问被拒绝(使用密码:NO) - LAMP #1045 - Access denied for user 'root'@'localhost' (using password: NO) #1045-用户'root'@'localhost'的访问被拒绝(使用密码:是) - #1045 - Access denied for user 'root'@'localhost' (using password: YES) ERROR 1045(28000):用户'root'@'localhost'拒绝访问(使用密码:NO) - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) OperationalError:(1045,“拒绝用户'root'@'localhost'的访问(使用密码:NO)”) - OperationalError: (1045, “Access denied for user 'root'@'localhost' (using password: NO)”) mysqldbcopy-错误1045:拒绝用户'root'@'localhost'的访问(使用密码:NO) - mysqldbcopy - Error 1045: Access denied for user 'root'@'localhost' (using password: NO) #1045 - 用户 'root'@'localhost' 的访问被拒绝(使用密码:是) - #1045 - Access denied for user 'root'@'localhost' (using password: YES) 1045, "拒绝访问用户 'root'@'localhost' (使用密码: NO)") - 1045, "Access denied for user 'root'@'localhost' (using password: NO)") django.db.utils.OperationalError: (1045, “访问被拒绝用户 'root'@'localhost'(使用密码:YES)”) - django.db.utils.OperationalError: (1045, “Access denied for user 'root'@'localhost' (using password: YES)”)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM