I have an issue getting to connect remotely to a MySQL database.
My current set-up is as follows: I have a windows 2008 Server at work, placed behind a router (fixed IP). The router has DMZ configured to the server, which works perfectly fine for everything else I have tested including web server, VPN, FTP, etc... The firewall of the Server is opened to the necessary services on the corresponding ports. I can telnet to all these ports decently.
The only thing that I cannot get to work is remotely connecting to a MySQL database. I have done all of the following:
- Forward port 3306 to the Server (through DMZ);
- Configure MySQL to bind to
0.0.0.0:3306
(it automatically does that when not supplying abind-address
); - Configure a user account in MySQL with access from
localhost
; - Configure the very same user account (same name, password, rights) with access from
'%'
; - Open port 3306 in the Windows Server's firewall.
I am subsequently trying to execute a PHP script from a hosted web server (elsewhere on the internet):
<?php
// Create connection
$conn = new mysqli(<host>, <username>, <password>);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
with <host>
, <username>
and <password>
being the corresponding and correct credentials.
This script simply times out without reply and gives the expected error Connection failed: Can't connect to MySQL server on '<host>' (110)
. I can also not telnet on port 3306. Connecting from localhost
works fine.
I don't know what else I have forgotten or done wrong. What am I missing?
I need this connection in order to keep my 'backup system' centralized on the hosted web server. I could run my 'backup system' locally on the mysql host, but that makes it harder to manage it from the central point. Beside that, I'd like to get it to work to actually know what's going on. I hate not getting this kind of thing to work.
Thanks for anyone who has ideas on what could be wrong.
Kenneth