So I setup a MySQL server on a dedicated server. I attempted to connect to it with this PHP script.
<?php
$servername = "******";
$username = "******";
$password = "******";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
Yes the ***** in my script are replaced with the proper information.
The Connection was refused with this error
Connection failed: Can't connect to MySQL server on '66.45.230.186' (111)
So I tried it from another host, I used http://www.rainbowspuppiessunshine.com/tools/dbtest/index.php
From here I also got an error :
Lost connection to MySQL server at 'reading initial communication packet', system error: 111
So I tried to connect to the MySQL from my VPS. I installed MySQL on it and made a connection through users "root" and "steam" and was able to access my database and add tables through that.
The VPS is hosted by the same host as my Dedicated server (running my MySQL server) so I figured perhaps since it was on the same LAN that might be why it was allowing a connection. So I decided to install a MySQL client on my local machine (HeidiSQL 9.1). I was able to make a connection with that client from my local machine (500 miles away from my Dedicated Server)
So I am absolutely clueless as to why I am able to connect to the MySQL remotely from another MySQL client, but I am unable to connect to it through any PHP script. I really didn't know there was much difference.
The MySQL server is a fresh install (other than setting up permissions for remote connections and adding a database with two tables). It's running on Ubuntu 14.04
+------------------+-------------------------------------------+---------------+
| user | password | host |
+------------------+-------------------------------------------+---------------+
| root | *367201834FD28DD7137E8947B4E1A1F5CAC4BBB4 | localhost |
| root | *367201834FD28DD7137E8947B4E1A1F5CAC4BBB4 | myserver |
| root | *367201834FD28DD7137E8947B4E1A1F5CAC4BBB4 | 127.0.0.1 |
| root | *367201834FD28DD7137E8947B4E1A1F5CAC4BBB4 | ::1 |
| debian-sys-maint | *AA9A40B349EDF9989A118FEFCF255353033F4A6D | localhost |
| steam | *367201834FD28DD7137E8947B4E1A1F5CAC4BBB4 | **.**.***.*** |
| steam | *367201834FD28DD7137E8947B4E1A1F5CAC4BBB4 | % |
| root | *367201834FD28DD7137E8947B4E1A1F5CAC4BBB4 | % |
+------------------+-------------------------------------------+---------------+
... was edited to hide the IP