knockoutned Posted February 7, 2010 Share Posted February 7, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/191261-cant-connect-to-mysql-server/ Share on other sites More sharing options...
jskywalker Posted February 7, 2010 Share Posted February 7, 2010 it might be a firewall between the webserver, and the database, ask your shared hosting provider Quote Link to comment https://forums.phpfreaks.com/topic/191261-cant-connect-to-mysql-server/#findComment-1008460 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.