Houston, we have a problem! Setting up Multi-DB with your support.

Hello guys, Merry Christmas (albeit late :slight_smile: )
I hope that you are all well. I am (in case you wonder)

Issue
Try to set up Multi-DB on ADDON DOMAIN.

I have followed the tutorial instructions found on your website and I got the following error:

Houston, we have a problem!
Looks like you need to create your new db's! If you're lucky, this link still works - click me
Database Error: Access denied for user 'site_user'@'localhost' to database 'site_devsitedb'

When I hit “click me” I get a 404 not found page

Background
Using shared web hosting service, WP3.8 installed in root folder, Multisite subfolders, buddypress installed as second blog.
Main site (live site): site.com
Second site (ADDON DOMAIN, development site): devsite.com

127.0.0.1 localhost
12.222.222.222 devsite.com

Note:
12.222.222.222 is a fictitious IP address for the purpose of this explanation.

Wp-config.php (ADDON DOMAIN, devsite.com)
define('DB_NAME', 'site_devsitedb');

My note: when I create a new database using cPanel, mySQL Databases, the database name prefix is equal to the domain name (site_). Hence database name: site_devsitedb

define('DB_USER', 'site_user');
define('DB_PASSWORD', 'xxx');
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
$table_prefix = 'wp_';

Let’s begin!

STEP 1
I want to create 16DB

STEP 2
1. Select the DB SQL link and type your database name (same name as your default WordPress DB) followed by an underscore (_). Choose the number of databases and click “Submit”. DONE!

DB Name: devsitedb_

2. I don’t need to create VIP databases

3. Now, you need to create the databases either via command line (hardcore) or through phpMyAdmin. Log into your server and if you’re using phpMyAdmin you’ll enter the instructions generated above here. DONE!

4. One final step is to make sure you have assigned a username and password to be associated with each database. DONE!

My note:
I have added site_user to all 16DB using cPanel, MySQL Databases.
I have granted all privileges when adding site_user to the databases.

STEP 3
Now that are databases are created and in place, it’s time to start configuring the plugin to handle the heavy lifting. We’ve got 5 separate areas to configure here (6 if you’re using VIP databases)

Line 10: Change the DB_SCALING to however many databases you’re using (16). DONE!

Line 16: Don’t let this scare you. It just needs your server’s IP address.
Question: What server IP address should I put in Line 16? (please see IP Addresses provided in the background paragraph above for more information).

Line 25: Provide the same name you assigned for your global database in Step 2. example ‘dbname_global’
Observation - This is confusing. In STEP 2 to I have created the devsitedb_ database as per tutorial instructions. Not devsitedb_global

Question: could you please advise what I should put in Line
25?

Fill in your DB Name: (same as in step 2), Your DB Username and Password, For DB Local Host enter you server IP again. If you’re using a Remote Host enter that here, if you’re not just leave it blank. Finally select the number of databases you created and click “Submit”.

Observation – the statement “For DB Local Host enter you server IP again. If you’re using a Remote Host enter that here, if you’re not just leave it blank.” is confusing.

Question – given the information contained in the background paragraph above, what should I type in the form below?

DB Name:
DB User:
DB Pass:
DB Local Host:
DB Remote Host:

4. You’ll want to copy and past these lines directly above the commented out “VIP Blogs” section. DONE!

5. Finally, we’ll add the line for our global database, directly above the lines you just pasted. Assuming you used “global” for your global database.
Observation – the statement “Assuming you used “global” for your global database.” is confusing.
Question – how do I know whether I am using “global” for my global database?

The main database is devsitedb from which I have created a new database devsitedb_, (underscore) as instructed in STEP 2.1 in the Multi-DB tutorial.
I then run your script which created lines of code that I have run in myPHPAdmn SQL to generate 16 new database site_devsitedb_0, site_devsitedb_1, site_devsitedb_2, etc.

Given the information that I have given you so far in this post, could you please clarify what goes in between quotation marks in the code below, which precedes the 16 lines of codes, one for the newly created database?

add_db_server('global', 'dc1', 1, 1,'remotehost','localhost', 'dbname_global', 'dbuser', 'dbpass');

STEP 4
1. Open move-blogs.php and scroll down to line 19 for the Config section. DONE!

2. Configure lines 19-29 with the correct information as asked for in the file. DONE!

Remember that these configurations are all for your original WordPress database – not the new ones we are creating.
Observation – the statement “Remember that these configurations are all for your original WordPress database – not the new ones we are creating.” is confusing.

Given the information that I have given you so far in this post, could you please clarify what goes in between quotation marks in the code below?

///DB Settings
$dbname = '';
$blog_table_prefix = 'wp_';
$newdb_prefix = '';

//We need info to connect to the databases
$dbhost = '';
$dbuname = '';
$dbpass = '';

//How many db's are you moving into (16, 256, or 4096)?
$db_scaling = '16';

Conclusion
Well, thank you for reading. And I hope my questions make sense. If you prefer to take this post off-line you can emal bzarro76[at]gmail[dot]com

Thank you for providing one of the best support and service that I have ever experienced in the last few years. Best wishes, the fixer.

For completion of information I have attached move-blogs.php and db-config.php code below.

move-blogs.php

///DB Settings
$dbname = 'site_devsitedb'; //This is your current database
$blog_table_prefix = 'wp_'; //Prefix of your wpmu blog tables, most likely this won't need to be changed
$newdb_prefix = 'site_devsitedb'; //This is the prefix of the db's you're moving your tables into - we assume they are all the same, if not, you're in trouble

//We need info to connect to the databases
$dbhost = 'localhost';
$dbuname = 'site_user';
$dbpass = 'xxx';

//How many db's are you moving into (16, 256, or 4096)?
$db_scaling = '16';

db-config.php

//------------------------------------------------------------------------//
//---DB Scaling-----------------------------------------------------------//
//------------------------------------------------------------------------//
// 16,256,4096
define ('DB_SCALING', '16');
//------------------------------------------------------------------------//
//---DC IPs---------------------------------------------------------------//
//------------------------------------------------------------------------//
// Usage: add_dc_ip(IP, DC)
// EX: add_dc_ip('123.123.123.', 'dc1');
add_dc_ip('127.0.0.1', 'dc1');
//------------------------------------------------------------------------//
//---Global Tables--------------------------------------------------------//
//------------------------------------------------------------------------//
// Do not include default global tables
// Leave off base prefix (eg: wp_)
//
// Usage: add_global_table(TABLE_NAME)
// EX: add_global_table('something');
add_global_table('site_devsitedb');
//------------------------------------------------------------------------//
//---DB Servers-----------------------------------------------------------//
//------------------------------------------------------------------------//
// Database servers grouped by dataset.
// R can be 0 (no reads) or a positive integer indicating the order
// in which to attempt communication (all locals, then all remotes)
//
// Usage: add_db_server(DS, DC, READ, WRITE, HOST, LAN_HOST, NAME, USER, PASS)
// EX: add_db_server('global', 'dc1', 1, 1,'global.mysql.example.com:3509','global.mysql.example.lan:3509', 'global-db', 'globaluser', 'globalpassword');
//
// Note: you can also place this section in a file called db-list.php in wp-content
// EX: add_db_server('global', 'dc1', 1, 1,'global.mysql.example.com:3509','global.mysql.example.lan:3509', 'global-db', 'globaluser', 'globalpassword');
add_db_server('global', 'dc1', 1, 1,'','127.0.0.1', 'site_devsitedb', 'site_user', 'xxx');

add_db_server('0', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_0', 'site_user', 'xxx');
add_db_server('1', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_1', 'site_user', 'xxx');
add_db_server('2', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_2', 'site_user', 'xxx');
add_db_server('3', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_3', 'site_user', 'xxx');
add_db_server('4', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_4', 'site_user', 'xxx');
add_db_server('5', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_5', 'site_user', 'xxx');
add_db_server('6', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_6', 'site_user', 'xxx');
add_db_server('7', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_7', 'site_user', 'xxx');
add_db_server('8', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_8', 'site_user', 'xxx');
add_db_server('9', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_9', 'site_user', 'xxx');
add_db_server('a', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_a', 'site_user', 'xxx');
add_db_server('b', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_b', 'site_user', 'xxx');
add_db_server('c', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_c', 'site_user', 'xxx');
add_db_server('d', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_d', 'site_user', 'xxx');
add_db_server('e', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_e', 'site_user', 'xxx');
add_db_server('f', 'dc1', 1,1,'','127.0.0.1', 'site_devsitedb_f', 'site_user', 'xxx');

  • thefixer

    Ari, thank you for gettin back to me. No I have not created the _global database.

    from Multi-DB tutorial

    There is one other database you’ll need to create (2 if you intend to provide a VIP database). To create these databases, you’ll just want to copy one of the lines generated from the database tool and use the same root database name with additional tags of “global” (and vip1, vip2, etc if needed). So you’re final output for this line will look something like this:

    CREATE DATABASE dbname_global DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

    The instruction is not clear to me. The instruction does not specify where to paste the line.

    The tutorial goes on saying

    Now, you need to create the databases either via command line (hardcore) or through phpMyAdmin. Log into your server and if you’re using phpMyAdmin you’ll enter the instructions generated above here

    From the tutorial, there is no evidence to suggest to paste the line in the code generated by the database tool with a view to copying and pasting ALL the lines to myphpAdmin, SQL panel to generate the 16DB.

    Hence the question, could you please explain where - in the code generated by the database tool - you want me to copy AND paste the line

    CREATE DATABASE devsitedb_global DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

    Thank you for your support.
    Regards, the fixer

  • thefixer

    Ari, thank you and apologies for late reply.
    All good here.

    As a reminder, I have 2 sites (blogs) running in my development environment, WP Multisite, subfolders set up. These are: devsite.com (blog id1) and devsite.com/buddypress (blog id2). There are no sites' users, except for the super admin user.

    FYI - I have re-run the tool to create 256 dbs as opposed to 16 dbs as originally posted in this thread.

    Now, I have followed your instructions in this thread and - when I accessed /wp-content/scripts/move-blogs - I was presented with a grey table, which showed some tables not in dbs ending _C8 and _global.

    I have executed Step 4 (start copy process) as requested in /wp-content/scripts/move-blogs.php, and in the status section all tables say table in new db (green color).
    However - in the new db section - I don't see all newly created dbs there... The only dbs listed are those ending in _c8 and _global

    Is this normal?

    Also in /wp-content/scripts/move-blogs.php, I have executed Step 4 (start copy process) twice. Is this a problem?

    In phpMyAdmin, the 256 dbs and the _global db are there, however I tables exist only in the dbs ending in _C8 (which is blog id2, buddypress installed as second blog) and in the db ending in _global. Is this normal?

    Finally, I have checked the db.php file for the list of global tables. How can I make sure that all global tables are listed there?

    Thank you for clarifying this to me and for the steer and support.

    Regards, thefixer

  • ckizer86

    I know i'm not staff, but if I understand you correctly, you're wanting to ensure that things went well since you only see the tables for the two different domains, correct?

    I recently did a 256 db setup on a clean install and it only showed tables for global. I tested things out by making about 10 different subdomain tests off the install and checked through some databases, and it put some sites into random databases. When I went back to the move-blogs.php it still only showed the global tables so I believe that's normal.

  • thefixer

    hi @ckizer86

    thanks for your reply.

    you're wanting to ensure that things went well since you only see the tables for the two different domains, correct?

    I have installed multi-db on the stage site: devsite.com

    in devsite.com I have two blogs: devsite.com and devsite.com/buddypress

    I can see tables in database ending in _c8 which is blogid=2, which is buddypress installed as second blog.
    I can also see tables in the db ending _global.

    I do not see tables in the other 255 databases. I guess this is normal as only have two blogs running:

    devsite.com and devsite.com/buddypress (as said above)

    Finally, I have checked the db.php file for the list of global tables. How can I make sure that all global tables are listed there?
    Shall I simply look into the global table and write down all tables in there and type the global tables in the db.php?

    I am just seeking clarity on whether this is normal.

    Thank you for reading.

    regards, the fixer

  • ckizer86

    As far as I know, you shouldn't need to configure anything in db.php. The only files should've been db-config.php and move-blogs.php, the only instruction I came across for db.php is to upload it along with db-config.php to your wp-content folder.

    To test to see if the databases are working properly, you can do as I did and create random sub domains and check your different databases to see if it seperated them into different ones (I created about 10) and when I verified I removed the random sub domains I created.

    A staff member may have another way to verify, but that's the course of action I took.

    Sorry if i'm not of much help.

  • aristath

    Plugin re-installed from scratch, following wp multisite fresh install on stage server.

    I'm glad you managed to figure this one out!

    \wp-content\scripts\move-blogs.php
    contains sensitive information such as database prefix table, etc, etc

    So does the wp-config.php file... Don't worry though, nobody has access to this information.
    Even if they enter that URL on their browser they won't be getting anything.

    How do you protect viewing wp-content in the htaccess?

    You can simply create a blank index.php file in that folder.

    Is this a good tutorial?

    Seems fine to me.

    I hope that helps!

    Cheers,
    Ari.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.