WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Error establishing database connection (11 posts)

  1. topdogdesign
    Member
    Posted 1 year ago #

    Moving Multisite from server to local server. Established virtual host, installed and connected WordPress Network site. Functioned good. Exported DB from outside server, did find and replace and ran the find and replace script. Still getting Error establishing database connection. What else could be the issue.
    I am using sub folders not subdomains and it is going from the root folder on the server to a sub folder on the virtual, can this be the issue?
    Thanks Top Dog

  2. Did you edit the wp-config.php to point to the new DB with the new username/passwords?

  3. topdogdesign
    Member
    Posted 1 year ago #

    No great thought. Let me ask you though. Understand about PW and Username but the DB name will not be the one carried over from the current but rather the one on the Virtual Server. Yes?
    Thank you so much. Will check later today.
    Top Dog Design.

  4. Understand about PW and Username but the DB name will not be the one carried over from the current but rather the one on the Virtual Server. Yes?

    None of that DB info gets carried over, most of the time.

    You almost always get a new DB username and password, and a new DB name.

  5. topdogdesign
    Member
    Posted 1 year ago #

    Just realized the config file is fine, the DB was exported from the server and imported to the DB on the localhost the one that WP configured during install. So editing the config isn't needed. When I try and login I receive the message
    _______________________________________________
    Error establishing database connection
    If your site does not display, please contact the owner of this network. If you are the owner of this network please check that MySQL is running properly and all tables are error free.

    Could not find site dev.new.com/wordpress. Searched for table wp_blogs in database multisiteDB. Is that right?

    What do I do now? Read the bug report page. Some of the guidelines there may help you figure out what went wrong. If you’re still stuck with this message, then check that your database contains the following tables:

    wp_users
    wp_usermeta
    wp_blogs
    wp_signups
    wp_site
    wp_sitemeta
    wp_registration_log
    wp_blog_versions
    ____________________________________________________________________

    I went into the DB and made sure I had all of the above. Any thoughts on this?
    Much appriciate your help.

  6. Just realized the config file is fine, the DB was exported from the server and imported to the DB on the localhost the one that WP configured during install. So editing the config isn't needed.

    You are incorrect. Editing the config file may be needed. In fact, in the majority of cases, it is.

    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'DBNAME');
    
    /** MySQL database username */
    define('DB_USER', 'USERNAME');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'PASSWORD');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');

    Go save yourself hours of hassle, and just verify that the DBName, Username, and password are correct, and that the host is correct. Normally it's localhost, some companies like to make it mysql.domain.com or similar :)

    However I assure you, in the vast majority of cases when you move your site to a new location, that is exactly what you must change.

  7. topdogdesign
    Member
    Posted 1 year ago #

    Hi Mike,
    Possibly I may have not been clear on moving the MU from server to local.

    Like regular WP I installed a "clean" WP on my localhost. Gave it a virtual domain and set up MU in the "clean" WP.

    Transfered the WP-content folder from server along with DB.
    Then replaced WP-content from server to "clean" install on localhost.

    Copy and pasted server DB into the DB associated with the "clean" install on localhost. After going in and changing the url from the server to local.

    That being said are you suggesting just downloading the entire site verbatim from server to localhost?
    then altering the config file to reflect the DB on localhost. If so, do I just go into MAMP and create new DB then import info from DB on server and change the urls?

    Thank you for your patience.
    Topdog

  8. It's Mika, with an A not an E.

    1) Did WordPress work before you copied the DB down?
    2) Did you remember to edit your wp-config to tell it that you're running Multisite? (That shouldn't give you this error, BTW, but you need to remember to do this)
    3) Did you verify all the DB information to make sure it's valid?

    I know I keep coming back to this, and it's for a reason.

    When all sites on a network say 'Error establishing database connection' that means that somewhere, some of your information in the wp-config.php does not match what your DB has, or your DB is down. Since you seem to be able to get into the DB via localhost (MAMP comes with phpMyAdmin, so you can doublecheck at http://localhost/phpMyAdmin/), one can assume the DB is up. If the DB is up, then the issue is WP can't talk to it.

    When WP can't talk to your DB, it's because

    a) Your connextion info is wrong
    b) Your DB is broken (try running a repair on the DB)

    If the repair doesn't help, go back to rule 1. It's probably a setup issue.

    You may as well go back and look at your table prefix too, but IIRC that gives a different error (it says you're not setup yet)

    $table_prefix  = 'wp_';

    We do have directions on how to move Multisite: http://codex.wordpress.org/Moving_WordPress#Moving_WordPress_Multisite

    And really that's all it is.

  9. topdogdesign
    Member
    Posted 1 year ago #

    Mika,
    Did WordPress work before you copied the DB down? Yes, established good functioning MU
    Did you remember to edit your wp-config to tell it that you're running Multisite? Yes, Because if I did not the site would not have functioned as a MU
    Did you verify all the DB information to make sure it's valid?Yes, double checked manually and ran the script I got off WP.org

    If the DB is up, then the issue is WP can't talk to it. Completely agree

    Your connextion info is wrong But if the connection were broken the initial WP MU install would not have worked.

    Will try running repair.

    Thank you. Will try again. Barb Quinn

  10. But if the connection were broken the initial WP MU install would not have worked.

    If and ONLY if you haven't made any changes to the DB. Which you did :) you imported another DB on top, which changes things, so you ALWAYS go back, double check your work, and the user names and passwords and DB slugs.

    This is also true for how I KNOW you edited your WP-config. Unless you mean to say you built a multisite and THEN wiped over it with your OLD DB, which I doubt, you had to have edited that config file, and in doing so, you MUST go back and review it.

    Look the TLDR is you screwed something up. Scrap it and start over, if you don't want to put forward effort into the debugging.

  11. topdogdesign
    Member
    Posted 1 year ago #

    Mika,
    I got it to work.
    1. Downloaded the entire site from server. No clean install and then set up MU.
    2. Download DB and changed urls to local host.
    I originally had the MU site in a folder titled WordPress on my virtual server along with other sites. What seemed to work is putting all the WordPress files directly into the root folder, eliminating the wordpress folder throughout the site in the DB and wp-config.
    Works great. I hope this helps someone else in the future.
    Thanks very much.

Topic Closed

This topic has been closed to new replies.

About this Topic