我尝试使用简单的python脚本连接到我的sql server。
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]
但是当我运行我的脚本时出现问题:
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)")
为什么他试图连接我笔记本电脑的ip地址而不是sql server?
答案 0 :(得分:2)
该消息来自MySQL服务器而不是MySQL驱动程序。服务器告诉您的是,不允许以笔记本电脑的IP为根连接。