I have a MySQL database, hosted by me on a Windows server, and I would like to query it from a remote webserver. When I try to connect to the MySQL database using PHP (I know, I should be using mysqli):
$connection = @mysql_connect("203.0.113.0:3306", "username", "password");
With or without specifying the port, after a long time of loading, I get this error with an errorno
of 2003:
Can't connect to MySQL server on '203.0.113.0' (4)
Here is what I get when I run netstat -n
in command prompt on the server that is hosting the MySQL server: http://pastebin.com/pbRJNqCZ. It filled up the screen so I couldn't copy everything, but I know that everything else was (I saw a couple ports with a value of 3306, which is the MySQL port):
TCP 127.0.0.1:port 127.0.0.1:port ESTABLISHED
When I run netstat -a | find "LISTENING"
I get: http://pastebin.com/Lqj2BrQK
Here's what I know so far:
- It isn't an error with the MySQL server not being up, because I can connect to it locally.
- It isn't an error with the webserver not being able to connect to MySQL databases, because I can connect to other databases
- It isn't an authentication error (The username and password are correct, and the remote server has permission)
- It isn't a port forwarding error, because the port
3306
is fowarded on both TCP & UDP. - It isn't an error with being able to connect to the machine the server is hosted on, because I can ping it fine.
- The server isn't only listening on the localhost interface.
skip-networking
andbind-address
are commented out in mymy.cnf
file.
How could I edit my connection code, or edit my MySQL server to fix this error?