C# Mysql 连接问题 - 连接尝试失败

标签 c# mysql asp.net

加载 C# ASP.net 页面时出现以下错误。

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

[SocketException (0x274c): 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] System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) +6528783 System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +130

[IOException: Unable to read data from the transport connection: 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.] System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +296 MySql.Data.Common.MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count) +47

[TimeoutException: Unable to read data from the transport connection: 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.] MySql.Data.Common.MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count) +204 MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count) +128 System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count) +262 MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count) +42
MySql.Data.MySqlClient.MySqlStream.LoadPacket() +64
MySql.Data.MySqlClient.MySqlStream.ReadPacket() +32
MySql.Data.MySqlClient.NativeDriver.Open() +253
MySql.Data.MySqlClient.Driver.Open() +22
MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) +208 MySql.Data.MySqlClient.MySqlConnection.Open() +625 UoRLive.iPadLayout.Page_Load(Object sender, EventArgs e) in c:\Users\Corbin Spicer\Documents\FinalYearProject\UoRLive\UoRLive\iPadLayout.aspx.cs:92 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51 System.Web.UI.Control.OnLoad(EventArgs e) +92 System.Web.UI.Control.LoadRecursive() +54 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772

背景:

当尝试连接到本地 MYSQL 数据库时,该脚本在本地计算机上完美运行,但是我已将其移至 smarterasp.net,设置了另一个 MYSQL 数据库,现在收到此错误消息。

唯一改变的是连接字符串:

public static string GetConnectionString()
    {


        string connStr = String.Format("server={0};user id={1}; password={2}; port={3};" +
                 "database=MYDATABASE_resources; pooling=false", "SQL5011.Smarterasp.net",
                 "DMYDATABSE_resources_admin", "MyPassword", "1433");


        return connStr;
    }

详细信息 100% 正确,我已通过使用 MYsql Workbench 连接到服务器来检查它们。

有什么想法吗?

最佳答案

1433 是默认 SQL Server 端口。

3306 是默认的 MySQL 端口。

关于C# Mysql 连接问题 - 连接尝试失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24979218/

相关文章:

c# - 重构多层if-then

c# - outlook 2010 addin c#:::自定义表单在客户端计算机上不起作用

php - 来自 mysql_fetch_array 的数组,带有选择所有内容的查询并没有保存所有值

c# - SignalR disconnect 在互联网断开/重新连接时未被调用

C# UWP SpeechRecognizer 问题

MySQL:在 SELECT 语句中获取循环记录

php - mysql select where limit, join where

c# - HTTPServerUtility.Transfer 是否比 Response.Redirect 在 asp.net 网站性能方面更有用?

asp.net - 允许在 asp.net 文本框中使用 html

c# - 如何规定方法的参数必须是stringS或string