After Multi-DB installation and server restart, can't connect to DB

I've migrated on multi-DB about 6 weeks ago, and it works great, both on production, on dev and on local VM. We've dropped the original cluttered DB shortly after migrating to multi-DB.

The local VM is restarted every day, and up until now, I had no problem connecting to the blogs with multi-DB installed.

Today however, I made a new VM, and imported the code and DB over it. All my other websites works great and connect to their respective DBs, but my WP-MU install wouldn't connect. It's looking for the original DB which was destroyed instead of trying to connect to the _global DB defined in the plugin.

Is there a way to make it work again ? Do I need to re-define something ?

This VM config is supposed to be shared and used with our contractors so we need a reliable way to reconnect the WPMU install with its new shiny multi-DB install.

Thanks

  • Jack Kitterhing
    • Code Norris

    Hi there @sgdf,

    Hope you're well today and thanks for your question!

    When you visit the site do you just get the "error establishing a database connection" message, or any other error messages as well?

    In your wp-config.php do you have the global database configuration?

    Please advise. :slight_smile:

    Thanks!

    Kind Regards
    Jack.

    • sgdf
      • Flash Drive

      Hello,

      yes, when I access the website, I just get the blank page with "Error establishing a database connection".

      The wp-config.php is configured as if it was using the original ( now dropped ) DB. This doesn't seem to be an issue in the other VM or in our production server even though the old DB doesn't exists anymore.

  • Jack Kitterhing
    • Code Norris

    Hi there @sgdf,

    Hope you're well today and thanks for the additional information.

    Can you send me through the following please to take a closer look at this.

    - In the subject field add "Attn: Jack Kitterhing"
    - Link back to this thread
    - Include admin/network access
    - Include FTP
    - Include cPanel (for database access).
    - Include the global DB username/password.
    - Include any relevant URLS for your site

    On the contact form, select "I have a different question", this ensures it comes through and gets assigned to me.

    https://premium.wpmudev.org/contact/

    Thank you!

    Kind Regards
    Jack.

    • sgdf
      • Flash Drive

      Hello, sorry I didn't came back to you earlier.

      The fact is that I can't give you all that because as I said, this is happening on a local virtual machine.

      What are some steps I can try to find out where the problem originates from ?

      Thanks !

  • Jack Kitterhing
    • Code Norris

    Hi there @sgdf,

    Hope you're well today! No problem. :slight_smile:

    So we can get this sorted, are you apache or nginx (we can enable different types of logging, depending). Hopefully showing something what's happening here.

    On the database in question, can you execute any SQL commands or does nothing work at all on the database?

    We're here to help. :slight_smile:

    Kind Regards
    Jack

    • sgdf
      • Flash Drive

      Hello!

      I run a debian 6.0.6, with apache 2.2.16 and mysql 5.1.73, with a PHPMyAdmin running.

      I have absolutely no issue connecting to the DB, running SQL commands either from PhpMyAdmin or from command line. The DB is imported using command line and appears well and with all the correct data.

      However, wordpress can't make the connection.

      It isn't a user rights issues as I use the same user a WordPress to connect to my databases either from PhpMyAdmin or from the command line.

      How can I enable logging for that issue ?

      Thanks

  • sgdf
    • Flash Drive

    Hello,
    thanks for the help.

    here's the wp-config.php file. I've redacted user name and password, but otherwise it's exactly the same as the one I'm using on the local VM.

    The DB name is the one of the older DB ( the one we forked with Multi-DB ) and does not exists on the new server.

    It was my understanding that Multi-DB would take over and use the suffixed _global DB to connect.

    By the way, I tried changing the wp-config.php to make it connect to the _global DB and it didn't resolve the issue.

    Thanks a lot !

  • Hoang Ngo
    • Code Slayer

    Hi @sgdf,

    Thanks so much for your information. Hmm, that's look fine. And I do sorry about this, which multidb, we will need an extra config, which is the /multi-db/db-config.php file, can you please send it here too?

    I'm sorry for this inconvenience and many thanks for your patience.

    Best regards,
    Hoang Ngo

  • Hoang Ngo
    • Code Slayer

    Hi @sgdf,

    Look like your setting missing the host for add_db_server, for now it's look like
    add_db_server('0', 'dc1', 1, 1,'','', 'blogs_sgdf_fr_0', 'REDACTED', 'REDACTED');
    Can you please update it to
    add_db_server('0', 'dc1', 1, 1,'localhost','localhost', 'blogs_sgdf_fr_0', 'REDACTED', 'REDACTED');
    And then try again please?

    Best regards,
    Hoang Ngo

  • sgdf
    • Flash Drive

    Hello, thanks for the input. I just tried changing that, WordPress is still giving me the blank page with "Error establishing a database connection"

    If I go to the wp-admin page, it says it's looking for the wp_blogs table in the blogs_sgdf_fr database ( which is the one set in the wp-config.php but which is not used anymore after the installation of multi-DB ).

    WordPress doesn't seem to acknowledge the presence of the multiDB plugin or any of the new databases...

  • sgdf
    • Flash Drive

    Hello.

    If I go to move-blogs.php I see the following page ( see 1.png ). So, I created an empty DB in my local VM with the good rights for the user, and then see the page in 2.png

    Why do I need to have a full fonctionning DB of the old base if I don't use it anymore ? And more importantly, why does it work on my production server and why does it not in my local VM.

    If my production server needs rebooting for whatever reason, I don't want my platform to be lost due to this.

    Thanks.

  • Vaughan
    • Support/SLS MockingJay

    Hi sgdf,

    Sorry for the delay, Our lead developer @Aaron has been extremely busy lately, but I have emailed him and asked if he could take a look into this for you. hopefully he should respond shortly.

    We appreciate your patience & apologies for the delays.

    Thanks

    • sgdf
      • Flash Drive

      Hello,

      that's one of the first things I did, it is mentioned in my first post opening this support thread.

      It doesn't work. I checked the mysql user rights countless times, I checked my databases, I can access all the databases from the command line with the mysql CLI and the same user as wordpress and I have no problem connecting.

      So...

  • Aaron
    • CTO

    In your previous post you said different:

    The wp-config.php is configured as if it was using the original ( now dropped ) DB. This doesn't seem to be an issue in the other VM or in our production server even though the old DB doesn't exists anymore.

    The DB name is the one of the older DB ( the one we forked with Multi-DB ) and does not exists on the new server.

    The details in wp-config.php need to match your new global db, or any other valid db and associated user/pass, even if empty.

  • sgdf
    • Flash Drive

    Ok. I feel so incredibly dumb. It is completely my fault actually, turns out, the SQL I was using to populate the local DBs were from the production site.

    WordPress didn't like it that in the "wp_blogs" table the domain was set to "blogs.sgdf.fr" ( the production URL ) and not "local.blogs.sgdf.fr" ( the local URL ). I also had to update the "wp_site" and "wp_options" tables.

    I changed that and the site worked immediately.
    Sorry I've been bothering you with this stupid issue which doesn't have anything to do with WPMU.

    In all fairness, the wordpress "Can't establish a database connection" page is really not helpful, and was actually misleading because there was actually a DB connection. We'll know that for next time !

    Thanks for the time and help. The issue is now closed.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.