无法连接到任何指定的MySQL主机。6.

无法连接到任何指定的MySQL主机。6.,mysql,asp.net,webserver,Mysql,Asp.net,Webserver,我在web服务器上托管了我的网站。 我在VisualStudio中使用服务器数据库运行我的网站,它运行得很好,但当我在web服务器上托管它时,一天后它开始给我这个错误。 有时某些页面工作正常,有时相同的页面会出现此错误。 有什么问题吗? 任何解决方案都将是可观的 这就是错误所在- 这是我的密码- 我的web.config文件包含连接字符串,如下所示 我是新手,请帮助我。当您尝试连接到其他非本地数据库时,需要允许远程请求 如何允许远程请求?我正在使用asp.net。如果它有时有效,有时无效

我在web服务器上托管了我的网站。 我在VisualStudio中使用服务器数据库运行我的网站,它运行得很好,但当我在web服务器上托管它时,一天后它开始给我这个错误。 有时某些页面工作正常,有时相同的页面会出现此错误。 有什么问题吗? 任何解决方案都将是可观的

这就是错误所在-
这是我的密码-
我的web.config文件包含连接字符串,如下所示


我是新手,请帮助我。

当您尝试连接到其他非本地数据库时,需要允许远程请求

如何允许远程请求?我正在使用asp.net。如果它有时有效,有时无效,那么这与此无关。这听起来像是达到了最大连接数。如果它有时有效,有时无效,那么很可能你达到了某种连接限制。可能是因为你没有正确处理你的连接。显示一些相关代码。同时,阅读并分享你的研究成果。正如您的标题所示,您不是第一个遇到此问题的人。理想情况下,可以通过有关您的设置(web服务器、数据库服务器设置)、您迄今为止所尝试的内容(查看日志、检查服务是否正在运行等)的更多信息来展开此问题。
    Server Error in '/AttWeb' Application.

Unable to connect to any of the specified MySQL hosts.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.]
   MySql.Data.MySqlClient.NativeDriver.Open() +1268
   MySql.Data.MySqlClient.Driver.Open() +22
   MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) +218
   MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() +287
   MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() +93
   MySql.Data.MySqlClient.MySqlPool.GetConnection() +65
   MySql.Data.MySqlClient.MySqlConnection.Open() +543
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +2086
   System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +278
   System.Web.UI.WebControls.ListControl.PerformSelect() +37
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +114
   System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e) +23
   System.Web.UI.Control.PreRenderRecursiveInternal() +88
   System.Web.UI.Control.PreRenderRecursiveInternal() +160
   System.Web.UI.Control.PreRenderRecursiveInternal() +160
   System.Web.UI.Control.PreRenderRecursiveInternal() +160
   System.Web.UI.Control.PreRenderRecursiveInternal() +160
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4775
private MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString);
    protected void keepData()
    {
        MySqlCommand cmd = new MySqlCommand("select deptName, year from subject where subId = '" + Request.Cookies["subject"].Value + "';", con);
        try
        {
            con.Open();
            MySqlDataReader result = cmd.ExecuteReader();
            if (result.Read())
            {
                Response.Cookies["deptName"].Value = result["deptName"].ToString();
                Response.Cookies["year"].Value = result["year"].ToString();
            }
        }
        catch (MySqlException s) { Label1.Text = "Connection Failed"; }
        catch (Exception ex) { Label1.Text = "Network Error"; }
        con.Close();
    }
    <connectionStrings>
    <add name="DBCS"
         connectionString="Server=MYSQL5016.SmarterASP.NET;Database=db_a0d03d_demo1;Uid=a0d03d_demo1;Pwd=***"
         providerName="MySql.Data.MySqlClient" />