我无法使用Python连接远程服务器MySQL。
first.py
#!/usr/bin/python
import MySQLdb
import second
DBHostname = second.hostname
DBuser = second.user
DBPWD = second.passwd
DB = second.db
dbcon = MySQLdb.connect(host=DBHostname,user=DBuser,passwd=DBPWD,db=DB)
dbcur = dbcon.cursor()
try:
dbcur.execute("select * from push_time where userid = %s", (e100075))
data = dbcur.fetchall() #Fetch all of the rows from query
for row in data : #Get Data's
wait_time = row[2]
print wait_time
dbcon.commit()
except:
dbcon.close()
second.py
#!/usr/bin/python
hostname = "192.12XX.XXX.XXX"
user = "user"
passwd = "password"
db = "dbname"
运行此程序后,我收到以下错误:
_mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host '192.XXXX.XXX.XXX' (2)")
我做错了什么?