Python SQL connect to wrong ip adress
Question: I'm trying to connect to my sql server using a simple python script.

    
    
    import MySQLdb
    
    db = MySQLdb.connect(host="192.168.0.156", user="root",
    passwd="Imnottellingyoumypassword", db="mydatabase") # name of the data base
    
    cur = db.cursor() 
    cur.execute("SELECT * FROM customers")
    
    for row in cur.fetchall() :
        print row[0]
    

But when I run my script something goes wrong:

    
    
    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 
    'root'@'192.168.0.107' (using password: YES)")
    

Why is he trying to connect to my ip address of my laptop instead of the sql
server?


Answer: That message is from the MySQL server and not the MySQL driver. What the
server is telling you is that connections as root from the IP of your laptop
aren't allowed.

