WordPress.org

Ready to get started?Download WordPress

Forums

Use of Hyperdb (3 posts)

  1. edealsbiz
    Member
    Posted 3 years ago #

    Hi,

    I'm preparing a WordPress Multisite installation, and I'm looking forward to using Hyperdb among other multidatabase plugins.

    It seems that Hyperdb is much more flexible, and that you can create and add databases when you need to, but on the other hand, there's a big lack of documentation on the use of this plugin.

    Besides the fact that the possibilities of Hyperdb configuration are somewhat endless, is there a site or any documentation on a sample hyperdb configuration which can serve as a "basic" :) installation which can grow as your needs?

    Thanks in advance for any help on this topic

    Eric

  2. edealsbiz
    Member
    Posted 3 years ago #

    Hi,

    I'm not surprised not getting any information on this topic, but it's worth at least trying :)

    To keep this threat up, I've found a little piece of cake on one of the possibilities of configuration of Hyperdb:

    Add the following lines near the top of wp-config.php

    define('WPMU', true);
    require('db-settings.php');

    Then add the blow code at the bottom of db-settings.php

    // a handy function for mapping blog tables to dataset
    function add_blog_tables($ds, $blog_id){
    add_db_table($ds, 'wp_' . $blog_id . '_comments');
    add_db_table($ds, 'wp_' . $blog_id . '_links');
    add_db_table($ds, 'wp_' . $blog_id . '_options');
    add_db_table($ds, 'wp_' . $blog_id . '_postmeta');
    add_db_table($ds, 'wp_' . $blog_id . '_posts');
    add_db_table($ds, 'wp_' . $blog_id . '_terms');
    add_db_table($ds, 'wp_' . $blog_id . '_term_relationships');
    add_db_table($ds, 'wp_' . $blog_id . '_term_taxonomy');
    }

    // add databases
    add_db_server('global', 0, 'mysql3326_1', 1, 1, 'localhost:3326', '', 'wpmu_db0', 'wpuser', 'thepwd');
    add_db_server('s1', 0, 'mysql3326_2', 1, 1, 'localhost:3326', '', 'wpmu_db1', 'wpuser', 'thepwd');
    add_db_server('s2', 0, 'mysql3306_1', 1, 1, 'localhost:3306', '', 'wpmu_db2', 'wpuser', 'thepwd');
    add_db_server('s3', 0, 'mysql3306_2', 1, 1, 'localhost:3306', '', 'wpmu_db3', 'wpuser', 'thepwd');

    // add global tables which are in global database
    add_db_table('global', 'wp_blogs');
    add_db_table('global', 'wp_blog_versions');
    add_db_table('global', 'wp_registration_log');
    add_db_table('global', 'wp_signups');
    add_db_table('global', 'wp_site');
    add_db_table('global', 'wp_sitecategories');
    add_db_table('global', 'wp_sitemeta');
    add_db_table('global', 'wp_usermeta');

    // add the tables for the first blog (created during wpmu installation)
    // the first blog's tables are in global database
    // of course, you can move it to any database you want
    add_blog_tables('global', 1);

    $dbsnum=3; // 3 additional databases
    $blogs_per_db=2; // each database serves 2 blogs

    for($db_id=1; $db_id<=$dbsnum; $db_id++){
    $dataset = 's' . $db_id;
    $max = $db_id * $blogs_per_db + 1; // include
    $min = $max - $blogs_per_db + 1; // include
    for($blog_id=$min; $blog_id<=$max; $blog_id++){
    add_blog_tables($dataset, $blog_id);
    }
    }

    you can find the full post here:
    http://huang.yunsong.net/2009/wpmu-hyperdb.html

    This configuration takes advantage of the flexibility of use of Hyperdb, you just add databases on the go as you need them...

    If you think about an improvement of this setup, you're welcome to leave a reply.

  3. FlashUK
    Member
    Posted 3 years ago #

    The current setup of HyperDB is even simpler than that.

    Copy the db-config.php file to you're main directory (where wp-config.php is, it overrides these settings) and copy db.php into the wp-content folder - and away you go.

    The post you linked to is quite old.

    Refer to the comments in the code and README file for up-to-date instructions. I may post some examples later.

Topic Closed

This topic has been closed to new replies.

About this Topic