How can many sites share 1 sql database?

Discussion in 'Site & Server Administration' started by cocoMonkey, May 10, 2007.

  1. #1
    Alright guys,

    How can i have one sql database for many websites?

    Will they all be able to read/write to the same database?


    Any help on setting this up would be great.

    Cheers.
     
    cocoMonkey, May 10, 2007 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    How depends on whether the sites are all on the same server or not but yes, it's possible.

    Read and write permissions depend on the user you log in with to access the database.
     
    T0PS3O, May 10, 2007 IP
  3. ThreeGuineaWatch

    ThreeGuineaWatch Well-Known Member

    Messages:
    1,489
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    140
    #3
    And of course, a database can have many users with granular permissions. You can run many sites from a single database and it is quite common to do that on shared hosting setups. Just make sure you prefix the table names with a unique descriptor for each site otherwise it can soon become a mess.

    (I am assuming you are not going to share the tables between sites? You might run into problems if you are.)
     
    ThreeGuineaWatch, May 10, 2007 IP
  4. QiSoftware

    QiSoftware Well-Known Member

    Messages:
    805
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    158
    #4
    Tables are the main drivers of a database. If he cannot share the tables then he cannot share the database across sites.

    I believe the answer is-- does your web host permit it.

    Q...
     
    QiSoftware, May 10, 2007 IP
  5. koolasia

    koolasia Banned

    Messages:
    1,413
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #5
    if all the sites are on 1 server then i think this is possible its based on permissions though
     
    koolasia, May 10, 2007 IP
  6. ThreeGuineaWatch

    ThreeGuineaWatch Well-Known Member

    Messages:
    1,489
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    140
    #6
    Some hosting plans come with one database. You can run several sites from a single database. Each site operating from a distinct table set of tables. For example, installing WordPress and phpBB in to the same database. This does not share tables between sites, but it does share the database.

    Or is the OP asking about sharing the same tables for multiple instances of the same software? For example, running phpBB on two or more sites and sharing certain tables like the user table across the sites? Which as I said above will lead you down an avenue with certain inherent issues.
     
    ThreeGuineaWatch, May 10, 2007 IP
  7. cyanide

    cyanide Peon

    Messages:
    483
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yes, it is definitely possible.
    Even if the sites are on a different server than the database. The server handling mysql will have to allow remote connections, however.
     
    cyanide, May 10, 2007 IP
  8. cocoMonkey

    cocoMonkey Active Member

    Messages:
    305
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #8
    Cheers guys,

    I'll have to give these ideas a go.

    I plan on using the same table on differnt websites, not just the same database.

    Cheers.
     
    cocoMonkey, May 10, 2007 IP