torres87
February 15th, 2010, 05:46 PM
I've got my website hosted on a linux shared hosting account, at ip address 123.123.123.123 (I'll refer to this as the web server, example ip obviously).
I've just installed mysql server on a cloud hosted server running ubuntu (ip 456.456.456.456) where I'm hosting the mysql database for the website.
I believe I've configured mysql server correctly to allow for remote connections from both my home pc (using mysql query browser) and from the web server, by adding 2 entries to both the 'user' and 'db' tables in the mysql database. The 'host' column in both tables I set to the ip address of my home connection, and the other row to the shared ip of the web server (123.123.123.123).
The problem is I can connect from my home pc with no problems, and also from the cloud hosted ubuntu server (via localhost connection) but any page in which I use php to connect from the linux web server I get the following error:
Can't connect to MySQL server on '456.456.456.456' (4)
Here's the php code I'm using to connect, which works fine connecting to a database on localhost, but not to the remote database:
$db= array(
"hostname" => "456.456.456.456:3306",
"username" => "root",
"password" => "password",
"database" => "app"
);
//connect to database
$link = mysql_connect($db["hostname"], $db["username"], $db["password"]);
if (!$link) {
die(mysql_error());
}
The cloud hosted server I'm running is Ubuntu server which I'm not hugely experienced in managing. Currently I'm doing everything through a SSH connection.
Can anyone help?
I've just installed mysql server on a cloud hosted server running ubuntu (ip 456.456.456.456) where I'm hosting the mysql database for the website.
I believe I've configured mysql server correctly to allow for remote connections from both my home pc (using mysql query browser) and from the web server, by adding 2 entries to both the 'user' and 'db' tables in the mysql database. The 'host' column in both tables I set to the ip address of my home connection, and the other row to the shared ip of the web server (123.123.123.123).
The problem is I can connect from my home pc with no problems, and also from the cloud hosted ubuntu server (via localhost connection) but any page in which I use php to connect from the linux web server I get the following error:
Can't connect to MySQL server on '456.456.456.456' (4)
Here's the php code I'm using to connect, which works fine connecting to a database on localhost, but not to the remote database:
$db= array(
"hostname" => "456.456.456.456:3306",
"username" => "root",
"password" => "password",
"database" => "app"
);
//connect to database
$link = mysql_connect($db["hostname"], $db["username"], $db["password"]);
if (!$link) {
die(mysql_error());
}
The cloud hosted server I'm running is Ubuntu server which I'm not hugely experienced in managing. Currently I'm doing everything through a SSH connection.
Can anyone help?