booberz
booberz

Reputation: 431

Python MySQLdb error

When I run my script it won't connect to mysql database, I can't find my host name from godaddy I just tried mysq.mydomain.com and mydomain.com. the login details for the database are correct.

Traceback (most recent call last):
  File "mysql.py", line 6, in <module>
    conn = MySQLdb.connect(host="?",user="?",passwd="?",db="?")
  File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'official_autotes'@'104.156.228.189' (using password: YES)")


------------------

my code

from threading import Thread
import urllib
import re
import MySQLdb

conn = MySQLdb.connect(host="?",user="?",passwd="?",db="?")

query = "INSERT INTO tutorial (symbol) values ('AAPL')"
x = conn.cursor()
x.execute(query)
row = x.fetchal()

Upvotes: 1

Views: 734

Answers (1)

Anju
Anju

Reputation: 641

Grand privilage to the user and ip trying to access the MySQL table using the Python code. To do the same, execute the following commands in the mysql shell.

GRANT <privileges> ON database.* TO 'user'@'ip' IDENTIFIED BY 'password';
flush privileges;

Upvotes: 1

Related Questions