1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Is it possible to have 1 database on 2 domains

Discussion in 'Hire a Freelancer' started by facebook fans, Jun 29, 2016.

  1. facebook fans

    facebook fans Junior Member

    Joined:
    Jun 15, 2013
    Messages:
    188
    Likes Received:
    43
    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
     
  2. RuthSam

    RuthSam Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 19, 2010
    Messages:
    3,814
    Likes Received:
    979
    Gender:
    Male
    Home Page:
    Usually if they are on the same server it's possible. Not with most shared hosting I have seen, only VPS or DEDI servers.
     
  3. rsharpe75

    rsharpe75 Newbie

    Joined:
    May 29, 2015
    Messages:
    29
    Likes Received:
    3
    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

     
  4. jntarnold

    jntarnold Junior Member

    Joined:
    Nov 10, 2010
    Messages:
    113
    Likes Received:
    35
    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...
     
  5. 5zz

    5zz Newbie

    Joined:
    May 23, 2016
    Messages:
    45
    Likes Received:
    15
    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.
     
  6. ija61

    ija61 Senior Member

    Joined:
    Mar 2, 2011
    Messages:
    969
    Likes Received:
    637
    Gender:
    Male
    Occupation:
    The first SEO economist:)
    Location:
    Romania
    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.
     
  7. ryandipranata

    ryandipranata Registered Member

    Joined:
    Jul 26, 2014
    Messages:
    79
    Likes Received:
    8
    Gender:
    Male
    If they in one server / hosting, yes its possible.
     
  8. casperwww

    casperwww BANNED BANNED

    Joined:
    May 24, 2016
    Messages:
    28
    Likes Received:
    2
    Gender:
    Male
    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%
     
  9. srb888

    srb888 Elite Member

    Joined:
    Jul 30, 2008
    Messages:
    3,267
    Likes Received:
    5,083
    Gender:
    Male
    Occupation:
    WebzSurfer
    Location:
    Sun, Mon, Tue, WTF, Sat!!! :)
    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: Jun 30, 2016