Wordpress Multisite “Error establishing a database connection” in localhost

后端 未结 11 1357
北荒
北荒 2020-12-24 14:04

When attempting to convert WordPress to a Multisite setup, I get the error:

Error establishing a database connection

I\'m using

11条回答
  •  孤城傲影
    2020-12-24 14:23

    I had a strange encounter very recently. After setting up a dev server which runs under a different domain and moving a multisite setup to it I got the same error “Error establishing a database connection”. I had checked that all the wp_options tables have the correct domains in the respective settings and that my database connection had the right credentials and would work under normal circumferences.

    I found a way to get a better error reporting. I added an output of the database object in the function dead_db() in functions.php which then showed me that it couldn’t find any blogs for my site in the table wp_blogs. I simply forgot to update the domains for the test server in this table.

    function dead_db() {
      global $wpdb;
    
      echo "
    ";
      print_r($wpdb);
      echo "
    "; wp_load_translations_early();

    Hope that helps someone :)

提交回复
热议问题