开发者

Error when trying to execute a Python program that uses MySQL

I have a python program which makes use of MySQL database.

I am getting following error.

It would be very grateful if some one help me out a solution.

Traceback (most recent call last):
File "version2_1.py", line 105, in 
refine(wr,w)#function for replacement
File "version2_1.py", line 49, i开发者_高级运维n 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)")


You need to read about permissions and security within MySQL. Have a look at these links:

  • Overview: http://dev.mysql.com/doc/refman/5.1/en/privilege-system.html
  • Account administration: http://dev.mysql.com/doc/refman/5.1/en/account-management-sql.html

It could be that your user is not allowed to connect at all, or that it is only allowed certain types of queries. It could be that your remote host is not allowed to connect to the MySQL server. All of these considerations should be made when establishing grants for MySQL users.


run this command in console

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


Looks like you have an incorrect username/password for MySQL. Try creating a user in MySQL and use that to connect.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜