1

I'm trying to connect a MySQL database with a C# application, the MySQL database is mounted on a server in a LAN with access to internet. So, I need to connect that database using C#. The most of the answers I have found, explain that in the connection string use the IP of the server, but the IP of the server, in this case, is a private IP, the public IP is the IP of the modem or access point, where the server obtain the Internet access. Basically, the topology is: Application's Computer - Access point - Internet - Access point - Server with private IP. Any help or comment will be appreciated.

1 Answer 1

1

If you are on the same LAN as the database server than you should just connect directly to the private LAN ip. If it is going through an access point or your main firewall, then you need to setup the appropriate port forwards between the AP and the private server so that it forwards the port requests appropriately. If those forwards are not in place, you will not be able to connect to it form the WAN side as the AP needs to know where to forward those requests.

Example

Request on Port 3306 -> Public AP -> Forward Rule (3306 to LAN IP 192.168.1.105) -> Request forwarded to 192.168.1.105

Without the rule, the AP will just drop the request because it want's nothing to do with it

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

7 Comments

As I understand, my string connection will be: "SERVER=(IP of the AP);Port=3306;DATABASE=mydb;UID=user; pwd=pass;" But in the AP where is the server, I have to set the port "3306" to MySQL Service and redirect the request to the server, Is that coorect?
Yes, you will need to setup the proper port forwarding on the AP so that it knows where to send the request when it sees a request on that port. Is the server on the same LAN as the client?
The server and the client are in different LAN.
Ah ok, well then yes the rules apply. The AP that handles your WAN requests on the side of the MySQL server will need to be configured to properly forward those requests to the server on it's LAN
I have already configured the port in the AP, but when I try to connect to the MySQL database, I get the error "Unable to connect to any specified MySQL hosts".
|

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.