1

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, 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)")
OMG Ponies
334k85 gold badges536 silver badges509 bronze badges
asked Apr 9, 2011 at 17:37
2
  • 1
    Why do you specify localhost twice? Commented Apr 9, 2011 at 17:48
  • oops sorry, but I corrected that mistake and now I am getting the same error with this line db = MySQLdb.connect("localhost","root","anusha","anusha" ) Commented Apr 14, 2011 at 7:38

3 Answers 3

2

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

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.

answered Apr 9, 2011 at 17:49
Sign up to request clarification or add additional context in comments.

Comments

1

run this command in console

mysql> grant all privileges on *.* to 'user'@localhost identified by 'password' with grant option;
answered Feb 4, 2013 at 9:34

Comments

0

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

answered Apr 9, 2011 at 17:40

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.