Querying Online Databases from localhost

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Blinky001
Forum Newbie
Posts: 2
Joined: Fri Jul 01, 2005 3:51 pm

Querying Online Databases from localhost

Post 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
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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;
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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
Blinky001
Forum Newbie
Posts: 2
Joined: Fri Jul 01, 2005 3:51 pm

Post by Blinky001 »

Cheers guys, given me a good direction to put my thought into. :)
Post Reply