Page 1 of 1

Querying Online Databases from localhost

Posted: Fri Jul 01, 2005 3:58 pm
by Blinky001
Hi Guys,

Firstly, is querying online databases from localhost/intranet servers possible?

Secondly, if it is could someone shed some light on how I would go about it....

Ideally a small part of the intranet system would just contain two sets of db connects:

$db1 = mysql_connect("onlinehostname", "username", "pass");
mysql_select_db("databasename", $db1);

$db2 = mysql_connect("offlinehostname", "username", "pass");
mysql_select_db("databasename", $db2);

but I'm guessing this is simple method is impossible.... is there a way to accomplish something similar? as I would like to be able to take parts of an online database into an offline one if they were approved...

Cheers :D

Posted: Fri Jul 01, 2005 5:23 pm
by Burrito
you'll have to have a mysql user account created on the remote server to enable you to query from it.

you'll also have to have a static ip as that account will be tied to your host (ip address).

ex:

Code: Select all

mysql> grant all privileges on db.* to username@22.22.22.22 identified by 'password' with grant option;

Posted: Fri Jul 01, 2005 8:24 pm
by Chris Corbyn
Burrito wrote:you'll also have to have a static ip as that account will be tied to your host (ip address).
Quick note. Depending upon the level of security you need you can also use wildards in the IP address so that anyone in a particular range can access the DB. Handy if you don't have a static IP but your ISP dishes out IP's in a certain range via DHCP ;)

Posted: Fri Jul 01, 2005 8:46 pm
by Burrito
d11wtq wrote:
Burrito wrote:you'll also have to have a static ip as that account will be tied to your host (ip address).
Quick note. Depending upon the level of security you need you can also use wildards in the IP address so that anyone in a particular range can access the DB. Handy if you don't have a static IP but your ISP dishes out IP's in a certain range via DHCP ;)
roger that

Posted: Sat Jul 02, 2005 6:34 am
by Blinky001
Cheers guys, given me a good direction to put my thought into. :)