Python-SQL连接到错误的ip地址

2024-06-16 12:29:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用一个简单的python脚本连接到我的sqlserver。在

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]

但当我运行脚本时,出现了一些问题:

^{pr2}$

为什么他要连接到我笔记本电脑的ip地址而不是sql服务器?在


Tags: import脚本hostdbmyconnectrootdatabase
1条回答
网友
1楼 · 发布于 2024-06-16 12:29:11

该消息来自MySQL服务器,而不是MySQL驱动程序。服务器告诉你的是,不允许以根用户身份从笔记本电脑的IP进行连接。在

相关问题 更多 >