>  Q&A  >  본문

C# MySQL 연결 문제: 지정된 MySQL 호스트에 연결할 수 없습니다.

<p>다음 코드를 실행했을 때 위와 같은 오류가 발생했습니다.</p> <pre class="brush:php;toolbar:false;">MySqlConnection mysqlConn=new MySqlConnection("server=127.0.0.1;uid=pankaj;port=3306;pwd=master;database=patholabs;"); mysqlConn.Open();</pre> <p>서버를 localhost로 설정하고 사용자를 루트로 설정하려고 했지만 다음 오류가 발생했습니다.</p> <pre class="brush:php;toolbar:false;">오류: 0: 지정된 MySQL 호스트에 연결할 수 없습니다. System.Transactions 위험: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft. com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>처리되지 않은 예외</Description><AppDomain>DBSync.exe</AppDomain><Exception>< ;ExceptionType> MySql.Data.MySqlClient.MySqlException, MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d</ExceptionType><Message>지정된 MySQL 호스트에 연결할 수 없습니다.</메시지><StackTrace> MySql.Data.MySqlClient.NativeDriver.Open()에서 MySql.Data.MySqlClient.Driver.Open()에서 MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder 설정)에서 MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()에서 MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()에서 MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()에서 MySql.Data.MySqlClient.MySqlPool.GetConnection()에서 MySql.Data.MySqlClient.MySqlConnection.Open()에서 c:Documents and SettingsTest01My DocumentsSharpDevelop ProjectsDBSyncDBSyncMainForm.cs:line 51의 DBSync.MainForm.BtnCalculateClick(Object sender, EventArgs e)에서 System.Windows.Forms.Control.OnClick(EventArgs e)에서 System.Windows.Forms.Button.OnClick(EventArgs e)에서 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)에서 System.Windows.Forms.Control.WmMouseUp(Message&amp;m, MouseButtons 버튼, Int32 클릭) System.Windows.Forms.Control.WndProc(Message&m)에서 System.Windows.Forms.ButtonBase.WndProc(Message&m)에서 System.Windows.Forms.Button.WndProc(메시지&m) System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp;m)에서 System.Windows.Forms.Control.ControlNativeWindow.WndProc(메시지&m) System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp;msg)에서 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 이유, Int32 pvLoopData) System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 이유, ApplicationContext 컨텍스트) System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 이유, ApplicationContext 컨텍스트) System.Windows.Forms.Application.Run(Form mainForm)에서 C : 문서 및 settingstest01my documentssharpdevelop projectdbsyncprogram.cs : line 27 & lt;/stacktrace & gt; & lt; exceptionstring & gt; mysql.datata.mysqlclient.mysqlcomement.mysqlemetmecome (0x8005).任何MySQL주.MySql.Data.MySqlClient.NativeDriver.Open()에서 MySql.Data.MySqlClient.Driver.Open()에서 MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder 설정)에서 MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()에서 MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()에서 MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()에서 MySql.Data.MySqlClient.MySqlPool.GetConnection()에서 MySql.Data.MySqlClient.MySqlConnection.Open()에서 c:Documents and SettingsTest01My DocumentsSharpDevelop ProjectsDBSyncDBSyncMainForm.cs:line 51의 DBSync.MainForm.BtnCalculateClick(Object sender, EventArgs e)에서 System.Windows.Forms.Control.OnClick(EventArgs e)에서 System.Windows.Forms.Button.OnClick(EventArgs e)에서 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)에서 System.Windows.Forms.Control.WmMouseUp(Message&amp;m, MouseButtons 버튼, Int32 클릭) System.Windows.Forms.Control.WndProc(Message&m)에서 System.Windows.Forms.ButtonBase.WndProc(Message&m)에서 System.Windows.Forms.Button.WndProc(메시지&m) System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp;m)에서 System.Windows.Forms.Control.ControlNativeWindow.WndProc(메시지&m) System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp;msg)에서 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 이유, Int32 pvLoopData) System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 이유, ApplicationContext 컨텍스트) System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 이유, ApplicationContext 컨텍스트) System.Windows.Forms.Application.Run(Form mainForm)에서 c:Documents and SettingsTest01My DocumentsSharpDevelop ProjectsDBSyncDBSyncProgram.cs:line 27</ExceptionString><DataItems><Data><Key>서버 오류 코드</Key><의 DBSync.Program.Main(String[] args)에 있습니다. Value>1042</Value></Data></DataItems></Exception></TraceRecord></pre> <p>저는 mysql Workbench를 사용하여 mysql Workbench를 사용하고 있습니다. 编辑:我注意到当我使usesharpdevelop时到错误,而在使用Visual Studio时没流现错误.</p>
P粉994092873P粉994092873426일 전479

모든 응답(1)나는 대답할 것이다

  • P粉078945182

    P粉0789451822023-08-21 15:06:06

    때때로 연결 문자열의 간격이 매개 변수의 순서와 관련이 있을 수 있습니다(개인 경험과 긴 밤을 기준으로 :S)

    표준 형식을 따르려면 여기

    를 참조하세요.

    회신하다
    0
  • 취소회신하다