[resolved] Which DB table is a user in? (11 posts)

  1. hobbleknee
    Posted 5 years ago #

    In WPMU 2.8.6 how can I find out which table a user's blog is in?

  2. dgilmour
    Posted 5 years ago #

    The data for a blog is held in multiple tables; standard ones for posts, comments etc and possibly others created by plugins or themes activated for the blog.
    In WPMU 2.8.6, Go to Site Admin > Blogs and find the blog's ID number. In a default install, the tables you need are those with the wp_<ID>_ prefix, e.g. wp_<ID>_posts.

  3. hobbleknee
    Posted 5 years ago #

    Thank you very much for the quick reply. I misspoke though, sorry. I meant, how do can I find which database a user's tables are in?

    In my WPMU installation, the blogs are spread over 256 DBs. So how do I know which DB a particular blog resides in?

    Thanks again for your help :)

  4. hobbleknee
    Posted 5 years ago #


  5. The plugin you're using is based on md5 hashes of the blog ID. So, for example, #1 is in db C if you have 16 (which I see you don't).

  6. hobbleknee
    Posted 5 years ago #

    Thanks, Andrea. Could you please tell me how to calculate it?

    Funny you should use #1 as an example, since that's the one (my own) that I'm interested in. I gather from your reply that the answer is different if I have 256 DBs.

  7. Yeah, but it still starts with a c. :)

    The people you bought the db plugin from also have a script/tut to determine this.

  8. hobbleknee
    Posted 5 years ago #

    ummmm... I'm not referring to any plugin. I'm just talking about default functionality of WPMU, before WP itself went multi. I got it from premium.wpmudev.org, I think. I thought that was pretty much the only one.

    Thanks for all the help, Andrea. You're a goddess.

  9. In default wpmu, there is but one database. The users are in the wp_users table, normally, iirc, and for each blog, you have to sort out what blog number it is blah blah blah what dgilmour said. I don't think the users table references the blogs a person has (it goes the other way, I believe) If your install is split across multiple db's that's a plugin and what Andrera said holds true.

  10. hobbleknee
    Posted 5 years ago #

    Aaaahhh... you guys are right. It's been so long, I forgot. I was using the multi-db plugin. Found what I was looking for, and here it is if anyone else was looking:

    $hash_value = md5($blog_id);
    				if (DB_SCALING == '16'){
    					$dataset = substr($hash_value, 0, 1);
    				} else if (DB_SCALING == '256'){
    					$dataset = substr($hash_value, 0, 2);
    				} else if (DB_SCALING == '4096'){
    					$dataset = substr($hash_value, 0, 3);
    				} else {
    					$dataset = substr($hash_value, 0, 1);
  11. Yeah, there's two more out there:

    I know Shard DB has a column to show which db a site is in.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.