如何将Python应用程序与在线数据库连接起来

我正在尝试将Python应用程序与在线数据库连接。它在本地主机数据库上工作正常,但当我尝试连接到在线时,它显示错误。

错误

errno=2003, values=(self.get_address(), _strioerror(err)))
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '69.162.107.34:3306' (10060 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)

代码

import mysql.connector
mydb = mysql.connector.connect(
                host="00.00.00.00",
                user="user",
                passwd="pass",
                database="db"
            )

mycursor = mydb.cursor()

解决方案

首先连接工作台,然后重试

相关文章