0

So I've port forward phpMyAdmin in order to access it from another network and it worked. I can access it from my browser by typing in xxx.xxx.com:8080. My problem is my program which I developed using VB.NET cannot establish a connection with the database(phpMyAdmin).

   Dim ServerString As String = "Server=xxx.xxx.com,8080;Database=hresource;Uid=trade;Pwd=1234"

      SQLConnection.ConnectionString = ServerString

    Try
        If SQLConnection.State = ConnectionState.Closed Then
            SQLConnection.Open()
             MsgBox("Succesfully Connected to MySQL Database.")
        Else
            SQLConnection.Close()
            MsgBox("Connection is Closed")

        End If
    Catch ex As Exception
        MsgBox(ex.ToString)

    End Try
    SQLConnection.Close()
    SQLConnection.Dispose()

It give off error when trying to open the connection.

3
  • xxx.xxx.com:8080 is just for Web server ... not MySQL server port Commented Feb 25, 2014 at 2:50
  • @TunZarniKyaw Technically that's not correct. While 8080 is commonly used as a secondary port for HTTP, ports above 1024 are not designated for any particular use. Furthermore, you can really use any port for anything if you want, although you might run into side-effects somewhere down the line. Commented Feb 25, 2014 at 2:55
  • @lc. thank your for pointing out ... OP says he can access phpMyAdmin in browser by typing xxx.xxx.com:8080 ... so that that 8080 must be using by Webserver ... i just mean it only for this case Commented Feb 25, 2014 at 2:58

1 Answer 1

2

phpMyAdmin is not what you want to port-forward; it is the MySQL server itself.

phpMyAdmin is simply a front-end administration tool human users can utilize from a browser, which acts as an intermediary between you and the database server. VB.NET however is expecting to connect directly to the database, and doesn't know anything about phpMyAdmin.

Sign up to request clarification or add additional context in comments.

4 Comments

Okay, I already port forward the MySQL server with port 3306. My program can now establish the connection but not all the time. Sometimes the connection failed and it gives off the same error like before. System.Net.Sockets.Sockets.SocketException : unreachable network xxx.xxx.xxx:3306 . I tried to ping the network address and it looks fine to me..
That's strange. Not sure it'll do anything useful but can you try a different port? I somewhat doubt it but something might be blocking or throttling 3306.
Maybe it's my own network problem. Thank you so much. One last question, let's say I want to change the port for the MySQL. Which port is the most suitable to use?
Honestly anything above 1024 should be ok as long as it doesn't conflict with another service on the network. You might want to avoid commonly used ports for peer-to-peer sharing though because some service providers may block traffic on these ports.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.