【发布时间】:2014-12-10 10:53:54
【问题描述】:
尝试连接到我的 VPS 上的 MySQL 数据库。使用以下代码时出现以下错误;
(我已经删除了我的凭据 - 但是我知道它们可以工作,因为我也将它们用于我的 PHP 开发人员。
代码
import mysql.connector as mysql
from mysql.connector import errorcode
try:
conn = mysql.connect( user= %USER%
,password=%PW%
,host = %HOST%
,database = %DB%
)
except mysql.Error as err:
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif err.errno == errorcode.ER_BAD_DB_ERROR:
print("Database does not exists")
else:
print(err)
else:
conn.close()
错误信息
2003: Can't connect to MySQL server on '%HOST%: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)
我正在使用的连接器
http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.1-py3.4.msi
知道我做错了什么吗?
【问题讨论】:
-
您为“HOST”使用的实际值是多少?
-
我的网站域名,例如www.DOMAIN.co.uk
标签: python mysql timeout connector