I've tried to install the Multi-DB plugin by following

I've tried to install the Multi-DB plugin by following the guide on your website.

When I run the move-blogs.php script to start the copy process (4), I keep getting an error though.

Warning: mysql_free_result() expects parameter 1 to be resource, string given in /home/wpxms/public_html/wp-content/scripts/move-blogs.php on line 140

Warning: mysql_free_result() expects parameter 1 to be resource, string given in /home/wpxms/public_html/wp-content/scripts/move-blogs.php on line 141

...

In the "new db" column, the databases are marked as "exists" and I have filled out all the credentials in db-config.php and move-blogs.php as far as I know.

One thing I'm unsure of though is whether to use 127.0.0.1 as IP of localhost or my server IP.

Any help is much appreciated. Thanks.

  • Alexander

    Hello @pixelmade,

    Are you experiencing any other problems? Those messages are actually not errors, rather only warnings. To explain what's happening:

    This script executes up to hundreds of MySQL database queries in order to get the blogs relocated to their new homes in the other databases. All of these queries start to take up more and more memory, and eventually the server would run out of RAM if this isn't done carefully.

    So the mysql_free_result() function is called to free up this RAM after each blog is processed. Sometimes there's nothing to free up, so this warning is given. It's nothing serious, or even a problem.

    As for using localhost or 127.0.0.1, it's really just up to you and what your host allows. I would usually stick with "localhost" if the database is running on the same machine.

    Is there anything else that isn't working here?

    Best regards, Alexander Rohmann

  • WPX

    Hello staff

    Thanks for your reply. I'm glad to know that the error messages are not referring to an actual error, but are only warnings, as you say.

    It is my understanding though, that the script process (move-blogs.php) should copy the table structure (blogs, blog_versions, commentmeta, comments etc.) from the existing main database to the new and empty 16 databases (_0, _1, _2 etc.) .

    After running the script (4) the "status column" on the "move-blogs.php" page says "table in new db" in green as it should, but all 16 databases still has no tables.

    Will the table structure of the empty database first be created, when future sites are created or is this incorrect?

  • PC

    Hello @pixelmade

    Greetings and thanks for standing by on this one and apologies for the delay in response as our staff handling this thread was away for a few days due to some family issues.

    It is my understanding though, that the script process (move-blogs.php) should copy the table structure (blogs, blog_versions, commentmeta, comments etc.) from the existing main database to the new and empty 16 databases (_0, _1, _2 etc.) .

    After running the script (4) the "status column" on the "move-blogs.php" page says "table in new db" in green as it should, but all 16 databases still has no tables.

    Will the table structure of the empty database first be created, when future sites are created or is this incorrect?

    moveblogs.php moves the existing blogs across the databases you have created and the tables will be created at the same time.

    Just to make sure we are on the same page, I have sent a note to our lead developer @Barry to provide his thoughts on these questions.

    I have also sent him an email to speedup the process.

    Cheers, PC

  • Barry

    After running the script (4) the "status column" on the "move-blogs.php" page says "table in new db" in green as it should, but all 16 databases still has no tables.

    How many blogs do you have in your original database to move>

    That error usually means that the username and password you have entered is not correct for the databases, but can also show depending on the configuration of your php / mysql setup. For some reason php-fpm shows this error more often than others.

    Can you pop up your move-blogs.php file so we can check the settings you have entered in that. Also, if you have set up your db-config.php file, then post that as well and we can do a quick check.

    One thing I'm unsure of though is whether to use 127.0.0.1 as IP of localhost or my server IP.

    Either really, I always use the IP address, some people use localhost.

  • WPX

    Hello support

    Since my last comment, I've been working to get the system up and running myself and believe everything is working correctly now, so I won't be uploading db_config.php and move_blogs.php files at this time.
    In case I need to do so later, if I run into future problems, will they be shown public (should I remove creds) or are uploaded files only shared with your staff?

    Now, to answer your questions:
    I currently have a setup with 16 databases.
    When I last wrote you, I didn't have multiple sites in the main database - only one.
    I was still in the process of fully understanding, how your script is working.
    Back then I thought that running the move_blogs.php script would populate the 16 databases with the table structure of the main database, but obviously that's not the case.
    In the meantime, I've created 17 test-sites to see how the database structure was building up. This is the current status of the database:

    0
    1 site05
    2
    3
    4 site08
    5
    6 site10, site17
    7 site16
    8 site06
    9 site14
    a site03, site13
    b
    c site01, site07, site11, site12, site15
    d site09
    e site02, site04
    f

    To fully understand the process, I have a couple of questions:

    1. Will sites just be spread out randomly in the 16 databases. As you can see there's still several empty databases, while db C currently holds 5 sites. I thought they would be evenly distributed?

    2. If I had created the 17 sites in the main database before running the move_blogs.php script, the script process would separate them from the main database and distribute them between the 16 databases? If that's the case, would I have gotten some kind of feed back/confirmation after running the script.

    Thanks (-:

  • Barry

    1. Will sites just be spread out randomly in the 16 databases. As you can see there's still several empty databases, while db C currently holds 5 sites. I thought they would be evenly distributed?

    It's not a random process, but they're not evenly spread either - the plugin generates an md5 hash of the id of the blog and then takes the first character of that hash to determine which database that particular blog should be placed in. Eventually, things will start to even out - but they won't be exactly level.

    2. If I had created the 17 sites in the main database before running the move_blogs.php script, the script process would separate them from the main database and distribute them between the 16 databases? If that's the case, would I have gotten some kind of feed back/confirmation after running the script.

    Yes, the report move-blogs.php would have returned would have displayed all the blogs that it was moving, the database it was moving them to and whether it succeeded or not.

  • Barry

    In case I need to do so later, if I run into future problems, will they be shown public (should I remove creds) or are uploaded files only shared with your staff?

    Always remove the usernames and passwords (global search and replace to something like 'username' and 'password' - this also helps find typographical errors in the config file - there have been a number of times when I've done a search and replace and spotted that I'd mistyped a username in the file and that was causing my problems :disappointed:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.