Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.