这是我在C#中的连接字符串:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="dbcon" value="Data Source=aServer;Failover Partner=bServer;Initial Catalog=enggdb;Persist Security Info=True;User ID=tt;Password=bb123;" />
</appSettings>
</configuration>
我的C#程序能够连接到服务器,但是,我的python程序无法连接
代码:
import mysql.connector
failoverConfig = {
'user': 'tt',\
'password': 'bb123',\
'database': 'enggdb',\
'host': 'bServer',\
}
config = {
'user': 'tt',\
'password': 'bb123',\
'host': 'aServer',\
'database': 'enggdb',\
#'failover': [failoverConfig ],\
}
conn = mysql.connector.connect(**config)
在禁用故障转移服务器的情况下,出现以下错误:
errno=2003, values=(self.get_address(), _strioerror(err)))
InterfaceError: 2003: Can't connect to MySQL server on 'aServer: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)
启用故障转移服务器后,出现以下错误:
raise InterfaceError("Could not failover: no MySQL server available")
InterfaceError: Could not failover: no MySQL server available
请告知。