2011-04-09 111 views
0

我有一個使用MySQL數據庫的python程序。
我收到以下錯誤。
如果有人幫我解決問題,我將非常感激。嘗試執行使用MySQL的Python程序時發生錯誤

 
Traceback (most recent call last): 
File "version2_1.py", line 105, in 
refine(wr,w)#function for replacement 
File "version2_1.py", line 49, in refine 
wrds=db_connect.database(word) 
File "/home/anusha/db_connect.py", line 6, in database 
db = MySQLdb.connect("localhost","root","localhost","anusha") 
File "/usr/lib/pymodules/python2.6/MySQLdb/_init_.py", line 81, in Connect 
return Connection(*args, **kwargs) 
File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 170, in __init__ 
super(Connection, self).__init__(*args, **kwargs2) 
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)") 
+1

爲什麼你指定'localhost'兩次? – bernie 2011-04-09 17:48:29

+0

哎呀對不起,但我糾正了這個錯誤,現在我得到了與此行相同的錯誤db = MySQLdb.connect(「localhost」,「root」,「anusha」,「anusha」) – Anusha 2011-04-14 07:38:53

回答

0

看起來您對MySQL有不正確的用戶名/密碼。嘗試在MySQL中創建一個用戶並使用它來連接。

0

運行此命令控制檯

mysql> grant all privileges on *.* to 'user'@localhost identified by 'password' with grant option; 
相關問題