1
當我使用命令「python manage.py makemigrations」時「python manage.py runserver」),它拋出了這個錯誤。然後我檢查了用戶的權限。代碼和結果如同fllows。django.db.utils.OperationalError:(1045,「拒絕用戶'root'@'localhost'(使用密碼:YES)」)
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 [email protected]% |
+---------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'zhuxin'@'%' WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `blogdb`.* TO 'zhuxin'@'%' |
+---------------------------------------------------------------+
mysql> show grants for 'root'@'%';
+--------------------------------------------------+
| Grants for [email protected]% |
+--------------------------------------------------+
| GRANT USAGE ON *.* TO 'root'@'%' |
| GRANT ALL PRIVILEGES ON `blogdb`.* TO 'root'@'%' |
+--------------------------------------------------+
我已經嘗試了一切來解決它,但沒有用。
噢提供
USER
和PASSWORD
,我已經改變了settings.py這樣的:數據庫= { '默認':{ 的 '發動機': 'django.db.backends.mysql', 'NAME': 'blogdb', '用戶': '根', 'PASSWORD': '1234', 'HOST': '', 'PORT': '', } }。但是錯誤仍然是 – Krimony@朱朱鑫,你是否可以用這個用戶和密碼檢查你是否可以通過mysql服務器進行身份驗證? –
Thks。我知道了 !我授權後將「localhost」更改爲「127.0.0.1」。但我不知道爲什麼。也許這就像你說我迷惑用戶。 – Krimony