title: How to connect to MySQL database from another PC online? VB.NET
body: <p>Here is my connection string</p>
  
  <pre><code>mySqlCon.ConnectionString = "server=testserver.noip.me; port=3306; database=testserver1; uid=admin; pwd=admin"
  </code></pre>
  
  <p>I have created a vb.net application with <em>TryCatch</em> function to check MySql connection.</p>
  
  <p>My <strong>server</strong> <code>testserver.noip.me</code> is a hostname of my <strong>public ip</strong> <strong>(The hostname is an example, if you check the port online, it wont work)</strong>. If I change the server to <strong>localhost/127.0.0.1</strong> or my <strong>private ip</strong> address which is something like <strong>192.168.0.xx</strong>, the result is connected just fine. Able to connect to database even on another PC but within the same wifi network.</p>
  
  <p>Whenever I change it to my public ip address or my hostname, the application returns an error message :</p>
  
  <blockquote>
    <p>"Unable to connect to any of the specified MySQL hosts."</p>
  </blockquote>
  
  <p>Here is the code</p>
  
  <pre><code>Try
          mySqlCon.Open()
  
          If mySqlCon.State = ConnectionState.Open Then
              Label5.Text = "Online"
              Label5.ForeColor = Color.GreenYellow
              LoginBtn.Enabled = True
          Else
              Label5.Text = "Offline"
              Label5.ForeColor = Color.LightPink
              LoginBtn.BackColor = Color.Red
          End If
  
          mySqlCon.Close()
      Catch ex As MySqlException
          If mySqlCon.State = ConnectionState.Open Then
              mySqlCon.Close()
          End If
  Finally
          mySqlCon.Dispose()
      End Try
  </code></pre>
  
  <p><em>I have also done port forward in my router and the result is fine :</em>
  <a href="https://i.stack.imgur.com/aGBMK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aGBMK.png" alt="enter image description here"></a></p>
  
  <p><em>And the hostname port 3306 check is open as well:</em>
  <a href="https://i.stack.imgur.com/RRfmz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RRfmz.png" alt="enter image description here"></a></p>
  
  <p><em>Extra info : I have installed connectornet and is using MySQL workbench for this.</em>
  <a href="https://i.stack.imgur.com/TBC52.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TBC52.png" alt="enter image description here"></a></p>
  
  <p>Everything is working fine on local network but not online. Any idea what I should do to make the application connect to the database successfully from another network online? No SSH or any secure connection guide please because this is just a test server.</p>