title: VB.NET Connect to MySQL Server Database
body: <p>I'm using the following code to connect to a MySQL database hosted with GoDaddy. According to multiple references, this <em>should</em> work, but I get the error:</p>
  
  <blockquote>
    <p>MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts. ---> System.Net.Sockets.SocketException (0x80004005): This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server</p>
  </blockquote>
  
  <p>Im wondering if I've configured something wrong as the words <em>Local Server</em> suggest that its not attempting to connect to the server at all?</p>
  
  <p>Code:</p>
  
  <pre><code>Imports MySql.Data.MySqlClient
  Module Licence_Check
  
      Dim conn As New MySqlConnection
  
      Public Sub ConnectToDatabase()
  
          Dim DatabaseName As String = "ALVEAREKEYSCHK"
  
          Dim server As String = "XXXX.db.XXXXXX.hostedXXXXX.com"
  
          Dim userName As String = "ALVEAREKEYSCHK"
  
          Dim password As String = "SXXXXXXXXXX!"
  
          If Not conn Is Nothing Then conn.Close()
  
          conn.ConnectionString = String.Format("server={0}; user id={1}; password={2}; database={3}; pooling=false", server, userName, password, DatabaseName)
  
          Try
  
              conn.Open()
  
  
  
              MsgBox("Connected")
  
          Catch ex As Exception
  
              Debug.Print(ex.ToString)
              MsgBox(ex.Message)
  
          End Try
  
          conn.Close()
  
  
      End Sub
  
  End Module
  </code></pre>
  
  <p><em>Some things have been replaced with X's</em></p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>In response to the answers, I've updated the code to:</p>
  
  <pre><code>    Dim conn As New MySqlConnection("server=SERVERNAMEHERE;uid=USERIDHERE;pwd=PASSWORDHERE;database=DATABASEHERE;")
      Try
          conn.Open()
          MsgBox("connection open")
      Catch ex As Exception
          Debug.Print(ex.Message)
      Finally
          conn.Close()
      End Try
  
  End Sub
  </code></pre>
  
  <p>Something seems to have changed as now I'm getting the following error:</p>
  
  <blockquote>
    <p>'<code>SERVERNAMEHERE</code>' for user
    '<code>USERIDISHERE</code>' using method 'mysql_native_password' failed
    with message: Access denied for user '<code>USERIDISHERE</code>'
    (using password: YES)</p>
  </blockquote>
  
  <p>I'm guessing this is a server side issue now? Is there something else I need to do?</p>