2003,“无法连接到‘192.168.1.xxx”上的 MySQL 服务器 (10060)
2003, "Can't connect to MySQL server on '192.168.1.xxx' (10060)
我刚刚在服务器上安装了新的 CentOS 操作系统并恢复了所有数据库。
我试图使用 Python 脚本从 Windows 远程获取数据。
它返回给我这个错误
PS C:\Python27\practice> python .\server_test_script.py
Traceback (most recent call last):
File ".\server_test_script.py", line 9, in <module>
db="transactions") # name of the data base
File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 193, in __init__
super(Connection, self).__init__(*args, **kwargs2)
mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on '192.168.1.XXX' (10060)")
我已经用 bind-address=0.0.0.0 更改了我的 /etc/my.cnf 文件。还有一件事,当我使用 yum 命令下载 mysql 时,它安装了 mariadb 服务器。这是问题所在,但我不认为两者都使用相同的软件包提供相同的服务。我已经将自己创建为具有所有权限的用户,但仍然没有用。
这是我的 Python 脚本
import MySQLdb
con = MySQLdb.connect(host="192.168.1.xxx", # your host, usually localhost
user="shubham", # your username
passwd="xxxxx", # your password
db="transactions") # name of the data base
cur = con.cursor()
def getTransactioncount():
cur.execute("select count(tid) from transaction")
row=cur.fetchall()
count=row[0][0]
return count
print getTransactioncount()
谁能帮我找出我哪里做错了
谢谢
检查从客户端到服务器的网络连接 - 很可能就是问题所在。另见 Cannot connect to remote MySQL with VB6 (10060) and http://dev.mysql.com/doc/refman/5.1/en/can-not-connect-to-server.html
我刚刚在服务器上安装了新的 CentOS 操作系统并恢复了所有数据库。 我试图使用 Python 脚本从 Windows 远程获取数据。 它返回给我这个错误
PS C:\Python27\practice> python .\server_test_script.py
Traceback (most recent call last):
File ".\server_test_script.py", line 9, in <module>
db="transactions") # name of the data base
File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 193, in __init__
super(Connection, self).__init__(*args, **kwargs2)
mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on '192.168.1.XXX' (10060)")
我已经用 bind-address=0.0.0.0 更改了我的 /etc/my.cnf 文件。还有一件事,当我使用 yum 命令下载 mysql 时,它安装了 mariadb 服务器。这是问题所在,但我不认为两者都使用相同的软件包提供相同的服务。我已经将自己创建为具有所有权限的用户,但仍然没有用。
这是我的 Python 脚本
import MySQLdb
con = MySQLdb.connect(host="192.168.1.xxx", # your host, usually localhost
user="shubham", # your username
passwd="xxxxx", # your password
db="transactions") # name of the data base
cur = con.cursor()
def getTransactioncount():
cur.execute("select count(tid) from transaction")
row=cur.fetchall()
count=row[0][0]
return count
print getTransactioncount()
谁能帮我找出我哪里做错了 谢谢
检查从客户端到服务器的网络连接 - 很可能就是问题所在。另见 Cannot connect to remote MySQL with VB6 (10060) and http://dev.mysql.com/doc/refman/5.1/en/can-not-connect-to-server.html