【发布时间】:2020-02-29 03:28:37
【问题描述】:
我正在尝试使用 python 从 Windows 连接到安装在 VMware 中的 CentOS 7 上的远程数据库服务器,但我无法连接到它。我正在使用mysql.connector访问数据库,请帮我解决问题。
import mysql.connector
mydb = mysql.connector.connect(host="192.168.136.129", user="root", passwd="root", database="test", port=3306)
mycr = mydb.cursor()
mycr.execute("CREATE TABLE cat (name VARCHAR(25));")
【问题讨论】:
-
任何错误信息?
-
你能从你的本地盒子成功ping通192.168.136.129吗?另外,VMWare 是否正确桥接到您的网络?
-
好的,我试试。感谢回复
-
虚拟机和windows都ping通了。而且 VMWare 正在桥接到我的网络。”mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '192.168.136.129:3306' (10060 A connection attempt failed because the connected party did not proper response after after一段时间,或建立连接失败,因为连接的主机没有响应)“。这是我面临的错误。
标签: mysql python-3.x linux database server