Reputation: 141
Ive been having this issue for weeks now. Currently we have an app that has to use a Mysql database hosted by Godaddy to access certain info, and php files on our in house server to access info from a legacy system (as we migrate slowly)
We want to put the MySql database onto the in house server so that we have no need to use godaddy anymore, and its much more manageable.
I have installed MySql and MySql workbench, i have confirmed that the service is running in the services on the server, i can get into localhost on workbench and create a table (see below)
And i can run querys locally etc.
The problem is when i try to query the database via php externally its not working and i have tried everything, ive even disabled the whole firewalls on the server and opened up port 3306. This is my php :
<?PHP
$user_name = "root";
$password = "dont be nosey";
$database = "tst";
$server = "myserveripaddress";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
if($db_handle)
{
print "Connected";
}
else
{
print "Can not connect to server";
}
if ($db_found)
{
print "DataBase found";
}
else
{
print "DataBase not found";
}
?>
and all i get is :
Warning: mysql_connect(): Can't connect to MySQL server on XXXXX (4) in /home/hiltonsmythe/public_html/gdad/testing.php on line 6
Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home/hiltonsmythe/public_html/gdad/testing.php on line 7
Can not connect to serverDataBase not found
Ive tried multiple users and yes they have % wildcard permissions. Any ideas? Also its worth mentioning i do have iis running on this server with php installed and i do query the database via that, so its not like the server is blocking - seems to be a mysql issue?
Upvotes: 1
Views: 105
Reputation: 1716
As shown in your nice picture, MySQL only listens to localhost connections.
You should adjust the bind-address
(or comment it out) in your my.cnf
(usually in /etc/mysql/my.cnf
) configuration file and restart mysqld
.
Upvotes: 1