Page 1 of 1
Connecting to remote database
Posted: Wed Jun 14, 2006 1:39 pm
by GeXus
I'm using plesk with several domains setup, I want to have multiple domains access a database on one of the domains. I assume this would be done by using a remote connection....... has anyone done this or have any insight as to how I would do this?
Posted: Wed Jun 14, 2006 4:12 pm
by feyd
Instead of using "localhost" as the host argument, you use the IP or domain name. The receiving database would have to be configured such that the user you are using has the rights to access from the given location you are requesting from.
Posted: Wed Jun 14, 2006 4:14 pm
by pickle
I'm not sure how you go about doing this with Plesk specifically. What you need to do is set the permissions on the database to be accessible either from '%' (anywhere) or make multiple entries for each ip of each domain you're wanting to have access from. Then, when you're connecting to the DB from PHP, just connect like:
Code: Select all
$connection = mysql_connect('IP of server',$username,$password);
However, if all the domains are on the same server, you shouldn't need to do anything. All the domains could just connect to 'localhost' without a problem.
Update: Dang! I've been 'feyded'!