Jump to content

Can't connect to MySQL server


knockoutned

Recommended Posts

I've got my website hosted on a shared hosting account, at ip address 123.123.123.123 (example obviously).

 

I've just installed mysql server on a cloud hosted server (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 server (local connection) but any page in which I use php to connect on the 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?  :)

 

Link to comment
https://forums.phpfreaks.com/topic/191261-cant-connect-to-mysql-server/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.