Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 14973

Unable to Access MySQL Remotely

$
0
0
I've opened a Stack Overflow thread here: https://stackoverflow.com/questions/...mysql-remotely but I'm asking again here. I really need help figuring this out to finish deployment.

I am using Windows Server 2016 attempting to host a PHP website via IIS that uses MySQL as the database and separately has a standalone desktop application written in VB.NET (.NET framework 4.7.2) that should also communicate with the MySQL database.

I was able to setup the website and I can hit it properly on an external network by navigating to https://mywebsite.com:8443/. I'm able to use my website which runs the PHP scripts which they in turn leverage the MySQL database on localhost:3306.

The issue comes when I attempt to access the database via the desktop application on an external network. If I connect to the machine via a VPN, setup my connection string so that the datasource is pointing to the internal IP address at port 3306, then I connect just fine. However, if I disconnect from my VPN, change the connection string so that the datasource is pointing to my public IP address, it fails to connect. What what it's worth, this is what the connection string looks like (the only thing changing is the datasource:
Code:

datasource=-public ip-;port=3306;username=dotnet;password=-password-;database=test;
The specific error I'm getting is:
Quote:

Unable to connect to any of the specified MySQL hosts.
If I change my port from 3306 to 8443 (which I don't think is right but I'm prepending it for my PHP website), I get a different error:
Quote:

Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I went down a rabbit hole and found that root did not allow for external request by default, which is why I created the dotnet user. From MySQL Workbench, these are the configurations for that user:
  • Authentication Type: Standard
  • Limit to Hosts Matching: %


I then read that the SQL server has a bind-address set to 127.0.0.1 by default, so I changed it to accept everything and verified by running:
Code:

mysqld --verbose --help
Scrolling until I found bind-address and the value it prints is *.

Finally, I read that I need to ensure that the firewall is setup properly. I go to Windows Firewall with Advanced Security, and see that a rule for port 3306 exists with the following properties:
  • Protocol type: TCP
  • Protocol number: 6 (disabled)
  • Local port: Specific Ports 3306
  • Remote Port: All Ports


At this point, I don't understand why it is connecting fine when VPNed to the machine, but fails when I try to connect from an external network.

Viewing all articles
Browse latest Browse all 14973

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>