2017-06-13 142 views
2

我想連接到在Python我的數據庫外殼_mysql_exceptions.OperationalError:1045「訪問被拒絕的用戶

import MySQLdb 
db = MySQLdb.connect(host="localhost",user="milenko",passwd="********",db="classicmodels") 

File "/home/milenko/anaconda3/lib/python3.6/site-packages/MySQLdb/connections.py", line 204, in __init__ 
    super(Connection, self).__init__(*args, **kwargs2) 
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'milenko'@'localhost' (using password: YES)") 

我已經創建了用戶

CREATE USER 'milenko'@'localhost' IDENTIFIED BY '8888888'; 

但問題仍然存在。 數據庫

mysql> show databases; 
+--------------------+ 
| Database   | 
+--------------------+ 
| information_schema | 
| ap1    | 
| classicmodels  | 
| mysql    | 
| performance_schema | 
| sys    | 
+--------------------+ 
6 rows in set (0.00 sec) 

這是什麼意思?怎麼解決這個問題?

回答

1

這通常意味着您沒有權限從該特定機器訪問服務器。使用您的根服務器的用戶來修復它,要麼創建用戶米倫科'@「localhost」的還是「米倫科」 @「%」

OR

授予特定的數據庫

+0

看看您的用戶權限在我的編輯! – MishaVacic

+0

好吧,現在您必須授予您對classicmodels的權限:'將classicmodels。*的所有權限授予'youruser'@'localhost';沖洗特權;' –

+0

完美的作品,謝謝! – MishaVacic

0

確保您的本地服務器(例如WampServer)已打開。

相關問題