You are not logged in.

#1 2005-07-29 04:06:03

viniosity
Member
From: Washington, DC
Registered: 2005-01-22
Posts: 377
Website

how to share one database?

I have this website: http://www.buyindie.net that is purely for DC at the moment.  I like the concept and some friends have expressed interest in expanding it to other cities.  Since I'm short of hardware (only 1 box) I'd like to have all the different cities on one machine.  Is it possible to do that?  Right now I'm using MySQL and it's set up as 1 master db with seperate tables for store, votes, comments, etc. 

Is there any way to keep the data structure but have clean data for the different cities?

Offline

#2 2005-07-29 04:56:13

iBertus
Member
From: Greenville, NC
Registered: 2004-11-04
Posts: 2,228

Re: how to share one database?

I love the concept behind your site. Nice job. Sorry I can't answer your question.

Offline

#3 2005-07-29 21:33:12

kth5
Member
Registered: 2004-04-29
Posts: 655
Website

Re: how to share one database?

well i'm not quite sure if that is what you mean but you could always authorize other servers to be syncing you db and run as slave. that should be documented well enough on mysql.com. no idea what exactly you're looking for though heh  wink


I recognize that while theory and practice are, in theory, the same, they are, in practice, different. -Mark Mitchell

Offline

#4 2005-07-29 21:57:39

viniosity
Member
From: Washington, DC
Registered: 2005-01-22
Posts: 377
Website

Re: how to share one database?

kth5 wrote:

no idea what exactly you're looking for though heh  wink

What I'm basically trying to do is have dc.buyindie.net sf.buyindie.net la.buyindie.net etc all running from one computer.  *Note those urls don't exist yet.)  Since the data will be different from dc to sf there needs to be some seperation, but the data structure (fields, types, etc) will be the same across all databases.  Since it's one box I don't know how to do it..

Offline

#5 2005-07-29 21:59:24

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: how to share one database?

viniosity wrote:

I have this website: http://www.buyindie.net that is purely for DC at the moment.  I like the concept and some friends have expressed interest in expanding it to other cities.  Since I'm short of hardware (only 1 box) I'd like to have all the different cities on one machine.  Is it possible to do that?  Right now I'm using MySQL and it's set up as 1 master db with seperate tables for store, votes, comments, etc. 

Is there any way to keep the data structure but have clean data for the different cities?

I hope I understood the question... but what you want to do is *not* use the master db, but create individual dbs per website...

for instance, let's say you have 5 sites, named: zach, jesse, ac, lisa, and screech...

create database zach_buyindie
create database jesse_buyindie
create database ac_buyindie
create database lisa_buyindie
create database screech_buyindie

then you just change your connection information in some sort of config file

function opendb($name, $host, $user, $pass)
{
   var $blark = 0
   $blark = @mysql_connect($host, $user, $password);
   if($blark) @mysql_select_db($name, $blark);

   return $blark;
}

var $zachdb = opendb("zach_buyindie","localhost","zach","morris");

(you should also create specific users per database too - i.e. the "zach" user will only have access to the "zach_buyindie" database)

disclaimer: I'm not a php guru, and the above may not work verbatim... but it should be close enough (I have no clue what the @ signs are for, but they were in what I used as a reference... maybe it has something to do with classes)

Offline

Board footer

Powered by FluxBB