这段代码工作正常:
import MySQLdb
db = MySQLdb.connect("localhost", "root", "","bullsorbit")
cursor = db.cursor()
cursor.execute("Select * from table where conditions'")
numrows = int(cursor.rowcount)
print 'Total number of Pages : %d ' % numrows
Run Code Online (Sandbox Code Playgroud)
但如果我提供我的IP地址
db = MySQLdb.connect("192.168.*.*", "root", "","bullsorbit")
Run Code Online (Sandbox Code Playgroud)
它会给出这个错误
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'ip address' (111)")
Run Code Online (Sandbox Code Playgroud)
小智 5
Code 2003是标准的MySQL客户端错误:
错误:2003(CR_CONN_HOST_ERROR)消息:无法连接到'%s'上的MySQL服务器(%d)
我猜你的用户不允许使用iP-address连接MySQL服务器.如果您尝试连接使用MySQL命令行客户端会发生什么?
$ mysql --host = 192.168.1.1 -u root bullsorbit
| 归档时间: |
|
| 查看次数: |
10390 次 |
| 最近记录: |