Is it possible to have 1 database on 2 domains

Status
Not open for further replies.

facebook fans

Power Member
Joined
Jun 15, 2013
Messages
558
Reaction score
229
Hi All,

i was wondering is it possible to have 1 database connected to 2 domains. for example if sample1.com makes a sell it would also deduct 1 item from sample2.com.

i have 2 domains its a long and boring task updating each site every time a item is sold. is there a way of doing this or a script that can be running so that it automatically deducts the item.


Thanks in advance for the advice and help.
Abz
 
Usually if they are on the same server it's possible. Not with most shared hosting I have seen, only VPS or DEDI servers.
 
Yes, this is possible. It shouldn't matter if it is a shared host either so long as the host doesn't restrict calls to the db. If they do, you can still work around this by requesting they allow calls from your other domain.

One thing you need to be mindful of is that the db does not have fully qualified links unless you don't mind links, images, etc. on blog2.com showing up as blog1.com/imagename.jpg

Hi All,

i was wondering is it possible to have 1 database connected to 2 domains. for example if sample1.com makes a sell it would also deduct 1 item from sample2.com.

i have 2 domains its a long and boring task updating each site every time a item is sold. is there a way of doing this or a script that can be running so that it automatically deducts the item.


Thanks in advance for the advice and help.
Abz
 
Yes, you can access a database from multiple domains. You define this in your server side access parameters. For instance in php a mysqli_connect statement...
 
One thing you need to be mindful of is that the db does not have fully qualified links unless you don't mind links, images, etc. on blog2.com showing up as blog1.com/imagename.jpg
Relative paths are stored, not absolute. If the script extracts base URL dynamically, then there's no troubles.

PS: It obviously brings up another issue - whether files are synchronized between different instances.
 
Yes it can be done no matter you are on shared, vps or dedicated and no matter you host the the domain on or outside the db server. With php and perl i can guarantee and I suppose there are others programs that can do it. Is true that connecting to a db outside your server is a little bit less secure.

In short words...it can be done.
 
surely, it is possible
i did this many time before without any problem, but if you going to transfer to new web hosting it will be difficult to make transfer without error by 100%
 
I have a huge database driven professional WP site, and during every major change on the site, while in our xampp development platform, we replicated the WordPress site into different sites, with different advanced changes in the sites -- features, different look, different custom home pages with different sets of data in each home page, etc, the test db was kept same for all our test sites. Faced no problems at all when the connectivity parameters in the WP sites were kept related to the same database.
 
Last edited:
Status
Not open for further replies.
This thread has been auto closed due to the forum's thread age policy. Read more.
Back
Top