gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 07:04:10 25 4
gpt4 key购买 nike

当我使用命令“python manage.py makemigrations”(与输入“python manage.py runserver”相同)时,它抛出了这个错误。然后我检查了用户的权限。代码和结果如下。

mysql> select host,user from mysql.user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| % | root |
| % | zhuxin |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
| localhost | zhuxin |
+-----------+---------------+


mysql> show grants for 'zhuxin'@'%';
+---------------------------------------------------------------+
| Grants for zhuxin@% |
+---------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'zhuxin'@'%' WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `blogdb`.* TO 'zhuxin'@'%' |
+---------------------------------------------------------------+

mysql> show grants for 'root'@'%';
+--------------------------------------------------+
| Grants for root@% |
+--------------------------------------------------+
| GRANT USAGE ON *.* TO 'root'@'%' |
| GRANT ALL PRIVILEGES ON `blogdb`.* TO 'root'@'%' |
+--------------------------------------------------+

我想尽一切办法解决它,但没有用。

最佳答案

您需要在project settings.py 中进行更改。为您的数据库提供 USERPASSWORD

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

关于mysql - django.db.utils.OperationalError : (1045, "Access denied for user ' root' @'localhost' (using password: YES)"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46619039/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com