Help needed on multiple DB plugin

Would anybody help me on how to do this?

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

The tutorial does not throw much light on how to do this except saying that this may be needed to done manually if we are not having VPS or a dedicated server.

Or do we encounter the interface to create usernames and passwords for the databases when we hit the button "GO" (located in phpmyadmin's "SQL" tab/interface)?

  • Alexander

    @aam,

    Sure, I can assist you with this. How far have you gotten already? Would you mind letting me know the steps you've taken so far? Do you already have a database created? If you're using cPanel, you could just use the MySQL wizard to do this for you.

    This instruction is more of a reminder to make sure you have a user that has access to these databases. You can easily create all the databases, but you will need to make sure there is a user assigned to them.

    By default, this is already done for you in phpMyAdmin. The user you used to create the databases will already have permission. However, you're free to create another user and assign the databases to that user instead.

    This is useful if you'd rather not use your root database user.

    Let me know if this clears things up, or if you need any more assistance here.

    Thanks for being a WPMU DEV member. Let us know if we can be of any further assistance.
    Best regards,

  • aam

    Alexander

    Thanks for your response.

    >How far have you gotten already?

    1. I have used the wpmudevtool at https://premium.wpmudev.org/db-tools/db_sql.php to create the instructions needed for mySQL to create the new DBs.

    2. I have also created the instruction for mySQL to create the new global DB.

    3. Although not instructed in the User Guide, I have the one-line instruction code to create the 'global' database appended at the end of list of instructions created from step 1. above. Am I correct in doing this?

    4. I will put the combined list of instructions from step 3. above into SQL tab of phpMyAdmin in my cPanel. BUT Before hitting "Go" on this page, I wanted to know how to assign the usernames and passwords for each database that will get created after I hit the button 'Go".

    So I started this thread.

    >By default, this is already done for you in phpMyAdmin. The user you used to create the databases will already have permission.

    So you mean to say that once I hit the button 'Go' in step 4, all the databases created can be accesses by the same user who created the database.

    >However, you're free to create another user and assign the databases to that user instead.
    How do you do this exactly? (how do you create ANOTHER user and assign the database/s already created to that user too?

  • aam

    Ok.. I have gone ahead and created the tables, manually assigned the users (I have kept all of them same as the user of the main db) to all the databases one by one from the MySQL Databases option available in Database Tools in cPanel, got the db-config.php ready too.

    Before I put forth the request for further assistance, I wish to state that Point 3 in my previous post [which reads as

    ( "Although not instructed in the User Guide, I have the one-line instruction code to create the 'global' database appended at the end of list of instructions created from step 1. above. Am I correct in doing this?)

    ]---- is incorrect: The instructions ARE available to append the instructions.

    ===========================================================
    (NOW I NEED THE HELP ON...)

    Now when I move to step 4, I see this on line 21 of the file move-blogs.php:

    $newdb_prefix = 'newdbname'; //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

    I need help on this line 21 mentioned above. I do not understand what I need to put in 'newdbname' - and I explain why I dont understand in the following lines.

    I am reproducing the comment in the code above:
    "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" ----------------------- (A)

    This is especially confusing because the comment says 'This is the prefix' whereas what is written between the code reads as newdbname. The confusion is further compounded when we take into consideration the comment below the image available in step 4, which reads as follows:

    "Remember that these configurations are all for your original WordPress database – not the new ones we are creating." --------------(B)

    I feel that there is inherent conflict in the statements (A) and (B). Statement (A) talks of the new DBs, while statement (B) talks of the old DBs

    But that's not all. When we look into the image (supposedly giving us a peek of the plugin developers progress on usage steps), it actually shows the current db name as masonjam_dbname_ and the prefix too as masonjam_dbname_ . Won't this lead to read the database name as "masonjam_dbname_masonjam_dbname_"? I know its not wrong but IMO, its kind of somewhat unusual to give the prefix same as the database name, unless I have not understand it correctly.

    Could anybody clarify me on these issues?

  • Alexander

    Hi @aam,

    I'm so sorry for not getting back to you before. I can certainly help clarify here. You're right, it is a bit confusing. All of the settings in step 4 are in fact the old settings, with the exception of $newdb_prefix

    I'm sorry about the confusion there. This variable exists to allow for custom setups outside of the directions. More advanced users might want to take the opportunity here to change their database name.

    The script won't duplicate the prefix. So if your prefix is "masonjam_dbname_" the tables it will look for would be something like:

    masonjam_dbname_0
    masonjam_dbname_1
    masonjam_dbname_2
    masonjam_dbname_4

    However, it's more likely that your prefix won't have multiple words. It might just be "dbname_" resulting in:

    dbname_0
    dbname_1
    dbname_3
    etc.

    Hopefully this helps! Sorry again about the delay. I'll be standing if you need any more help here.

    Best regards

  • aam

    Alexander

    Thanks for stepping in again.
    1.
    you said

    All of the settings in step 4 are in fact the old settings, with the exception of $newdb_prefix. --- This variable exists to allow for custom setups outside of the directions. More advanced users might want to take the opportunity here to change their database name.

    So what do you suggest I substitute the word newdbname with, in the following line of code?
    $newdb_prefix = 'newdbname';

    2.
    you also said -

    The script won't duplicate the prefix. So if your prefix is "masonjam_dbname_" the tables it will look for would be something like:
    masonjam_dbname_0
    masonjam_dbname_1
    masonjam_dbname_2
    masonjam_dbname_4

    This is prompting me to ask you another set of questions:
    Consider this:
    A.
    (Lets say) My hosting account name is aam

    B.
    So when I create a database using cPanel's Database Tools/MySQL Databases for WP installation (or for that matter any other application) with the database-name as (say) dbwp, it will by default pre-pend the word aam (my hosting account name) to wpdb (my given name) and it will show the name of the database after generation as aam_wpdb in the list of databases.

    Now, are YOU (and the multi-db plugin-code writer) referring to 'aam_' as the prefix of the database wpdb? I was of the opinion that the entire thing 'aam_wpdb' is the name of the database (...and that the prefix for this database is generated automatically in all WP installations, and is mentioned in the wp-config.php file by default as wp_)

    C.
    Taking it a level forward, while we make use of Multi-DB plugin, we are suggested to use the tool on the page https://premium.wpmudev.org/db-tools/db_sql.php to create the instructions (needed for mySQL to create your new DBs) in Step2.

    This Step2 asks us to feed the name of wordpress database (appended by '_'), feed the no. of databases we want to generate into the tool and hit the button 'GO'.

    So accordingly, I fed my wordpress database name as 'aam_wpdb_'

    The tool then generated the instructions with database names (I suppose that's what it is called- but I may be wrong) as aam_wpdb_XX, XX being the number/letters from 00 to 16 (or ff) (16 in case for generation of 16 databases, ff in case for 256 databases)

    So my questions are:
    In the output from the tool in Step2, we see "aam_wpdb_XX" for every database we want to generate. What do YOU (or the plugin-coder) call this 'aam_wpdb_XX'? Database name? Or the database name is ONLY XX and the prefix is aam_wpdb_' (your response as quoted in point 2 above seems to accord this logic of nomenclature)?

    I will appreciate specific answers to each of my questions, given after quoting each of my questions.

    Thank you for your patience in understanding my queries.

  • Alexander

    Hi again,

    I'm afraid if I just answer your questions inline, we may just confuse the issue more. I'm going to take a different approach here, and hopefully clear up any misconceptions.

    (...and that the prefix for this database is generated automatically in all WP installations, and is mentioned in the wp-config.php file by default as wp_)

    The "wp_" prefix actually has nothing to do with what were working with here. That is the table prefix. To be honest, it's not very useful nowadays, and is more or less just how we refer to the wordpress table names. Long ago, many hosting providers only allowed you to have 1 database. So web developers worked out a way for several applications to run off a single database. Each application used a prefix, and could then use any table name it liked without running into conflicts.

    "prefix" is a very relative term, and will mean different things in different contexts. In absolute terms, all that really matters is the final database names. In your case this would be instances of:

    aam_wpdb_XX

    aam_ can be considered a prefix as it is enforced by your hosting provided. But in this context, it is not the prefix we're referring to.

    aam_wpdb_ would be the prefix we're looking for in these directions. It is the name that all of your database tables are based on. When the move blogs script runs, it will use this prefix, and append anything from 00 to FF after it. Then it will move certain blogs into that database.

    At the end of the day, a prefix in this context really is just a way to identify what the database names are, it's not really special by itself.

    The tool then generated the instructions with database names (I suppose that's what it is called- but I may be wrong) as aam_wpdb_XX, XX being the number/letters from 00 to 16 (or ff) (16 in case for generation of 16 databases, ff in case for 256 databases)

    If this is true, then you did this correctly.

    Going back to the issue at Step 4. You would simply want both values set to "aam_wpdb_" The script provides two parameters in case you wanted to modify the script for an advanced installation, but if you're just following the directions they should be the same.

    Best regards

  • aam

    Alexander,

    Many thanks for your explanation.

    It was very helpful in going ahead with my procedure.

    I went ahead and did the balance procedure as you suggested below;

    Going back to the issue at Step 4. You would simply want both values set to "aam_wpdb_"

    ... but when I got the move-blogs.php to see in the browswer, I could not get the needed page that shows 9 instructions at the top, but instead, it gave an error message (sorry I did not take the screen shot for you to see).

    From whatever I could decipher from the error message, I removed the second underscore ('_') in "aam_wpdb_" mentioned in line 19 of move-blogs.php code, and I could see the needed page with all things as desired (i.e. "aam_wpdb" worked).

    I then went ahead and clicked on step 4 of this page and then after a while, refreshed the page using the link in step 6.

    The refreshed page did add the tables on the new database; but unlike the image in step 4 (of the plugin's usage instructions that shows the 9 instructions on top of the page), under the column "Table Info" I could only see blog2 mentioned in all the rows in my case. (i.e I did not see blog22 in any row under the the column "Table Info" in my case - which is the case in the example image). Further, there were a few additional rows - but I guess they were on account of the plugins installed and used and will keep getting added as I populate my WP installation with more child sites and plugin's usages. Am I correct with this understanding?

    I suppose I am done with this installation now but the following questions are the last of the lot I wish to have answers to:

    1. Is there nothing more to manage w.r.t. to this plugin now?

    2. With the new sites that get created now onward, will the data be automatically distributed across different databases for optimal functioning?

    3. Will I need to carry out any maintenance or anything like that ?

    4. There is no user-interface in the wp-admin's menu and we also do not see any trace of this plugin in the list of plugins installed. Is this how it is designed to be?

    5. At the end of instructions of this plugin's Usage Page, there is a note about upgrading the plugin by replacing the db.php file. If I have the wpmu dashboard plugin installed in my WP installation, will I be notified of any upgrade to this plugin automatically? If not how do I keep track of the updates/upgrades?

    6. I also noticed a file in the plugins folder that apparently did not serve any puprpose or use in the entire installation nor it was mentioned anywhere on the usage page. Its called fix-db-encoding.php. What is its purpose?

    Thank you once again for your continued patience in providing the assistance :slight_smile:

  • Barry

    From whatever I could decipher from the error message, I removed the second underscore ('_') in "aam_wpdb_" mentioned in line 19 of move-blogs.php code, and I could see the needed page with all things as desired (i.e. "aam_wpdb" worked).

    Yes, line 19 doesn't have the extra _ because that should be the name of your existing database that you are moving the tables from - the database that is specified in your wp_config.php file and that your single db wordpress install is using.

    Its called fix-db-encoding.php. What is its purpose?

    It's to fix the encoding of a database if it is needed. If it is not needed (i.e. we haven't said, "can you run fix-db-encoding.php"), then you don't need it :slight_smile:

    1. Is there nothing more to manage w.r.t. to this plugin now?

    No

    2. With the new sites that get created now onward, will the data be automatically distributed across different databases for optimal functioning?

    Yes

    3. Will I need to carry out any maintenance or anything like that ?

    No

    4. There is no user-interface in the wp-admin's menu and we also do not see any trace of this plugin in the list of plugins installed. Is this how it is designed to be?

    It's listed in the plugins page in the Network admin -> plugins page under the Drop-ins section.

    5. At the end of instructions of this plugin's Usage Page, there is a note about upgrading the plugin by replacing the db.php file. If I have the wpmu dashboard plugin installed in my WP installation, will I be notified of any upgrade to this plugin automatically? If not how do I keep track of the updates/upgrades?

    You should get a notification about a new release on the WPMUDEV dashboard plugin and we will post on the forum when a big update to the plugin is released. There aren't as many updates to this plugin as the others as once it is installed it pretty much just sits there and works :slight_smile:

  • aam

    Thanks a lot for joining the discussion, Barry :slight_smile: Your responses are really helpful. Plus I presume that the following point I raised is a non-issue and things as I describe are just fine.

    The refreshed page did add the tables on the new database; but unlike the image in step 4 (of the plugin's usage instructions that shows the 9 instructions on top of the page), under the column "Table Info" I could only see blog2 mentioned in all the rows in my case. (i.e I did not see blog22 in any row under the the column "Table Info" in my case - which is the case in the example image).

    Thanks a lot to you, Alexander. You have been very helpful in resolving my issues.

    For now, I guess I am fine with the Multi-DB plugin.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.