我创建了一个连接到服务器以从数据库中检索数据的系统,但是我得到了#34;类型' System.TimeoutException'未处理的异常。发生在MySql.Data.dll" ...
如果我连接到localhost就一切都很好....
string StrCon = string.Format("Server= Cant tell you ; database={0};UID= cant tell you ; password='cant tell you '", "cant tell you");
MySqlConnection Connection = new MySqlConnection(StrCon);
while (true)
{
//MySqlConnection Connection = null;
Console.WriteLine("not connected");
Connection.Open();
Console.WriteLine("connected");
string Query = "SELECT * FROM lat_long WHERE ID=1";
MySqlCommand cmd = new MySqlCommand(Query, Connection);
MySqlDataReader dr = cmd.ExecuteReader();
答案 0 :(得分:1)
确保主机上的防火墙未打开和/或mysql服务器绑定到0.0.0.0或接口地址 - 如果它绑定到127.0.0.1/::1,服务器将无法通过网络访问