Using Symbolic Links for MySQL Tables on Linux

  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

I currently have a site running off a MySQL (v3.23.56) database with a very large script. This script uses a $PREFIX variable on each of the tablenames. This way several copies of the script can run off the same database without interfering with each other. However, I am in a position where I need them to interfere with each other :)

I have two copies of the script installed on an account. Each of these different copies runs from the same database, with a different prefix for the table names. What I am attempting to do is to have each of these sites share a common userbase, however to have their own separate news, system settings, etc.

Is there a way to "fake" a table name?

For example, let's say the user database table names for the current sites are site1_users and site2_users. Is there a way to make site1_users look like it is also site2_users, so that..

Code: [ Select ]
select * from site2_users;

would produce the same results as...

Code: [ Select ]
select * from site1_users;

without actually having to have two separate tables and two separate copies of the data in those tables?

I guess essentially I'm lookin for MySQL's answer to symbolic links in the Linux filesystem.

Without this ability, my only option is to basically have a check in the theme header to see if the tables match, and if they don't, copy the extra records from one database over to the other. However, this could cause a lot of problems (as well as hog huge amounts of resources with 8K page views a day that one of the sites alone already receives), and the users table is one example of many that I wish to be common to both sites (links, downloads, informational articles, etc.)

So, is this feature available in my current version of MySQL (3.23.56)? If not, is this feature available in a more recent version of MySQL? And if not again, do you know if it's a planned feature for a future release?

Basically, there's tens of thousands of references to $PREFIX in the code, so sifting through all those (and any addons to the script that I may wish to install in the future) and modifying them specifically to use site1_users is going to be impossible.
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

You know what, I should listen to my own advice, lol.

After hunting around Google for 10 minutes, I figured out I could simply symlink the files through the shell.

As long as I remember to run optimize & repair on the original tables, and not the symlinks, I should be good to go.

So, rather than nuke my own post, I shall simply look silly, and leave this up here for future reference for others wishing to do the same thing :)

Using Symbolic Links for Tables on Unix
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

Nice link Axe. I'm going to change the title of this post, so that it reflects the solution. If you think it should be something else, go ahead and change it.
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

That's cool with me Rich.. I just can't believe it was as simple a solution as it was, lol.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 98 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.