When attempting to convert WordPress to a Multisite setup, I get the error:
Error establishing a database connection
I\'m using
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 "<pre>";
print_r($wpdb);
echo "</pre>";
wp_load_translations_early();
Hope that helps someone :)
I struggled a long time because of this issue. And finally found a solution.
You should not add all those settings at once in the wp-config.php file. Follow the exact steps described here: http://codex.wordpress.org/Create_A_Network
Only add the following code as the first step:
/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
And then refresh your page. After that, in your administration panel go to Tools -> Network Setup and choose your sub-site settings.
For the rest, just use the instructions from the link above.
Good luck!
Had same problem, found 3 possible solutions:
Make sure: DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST in your wp-config.php are really the ones expectected.
As Dima L. mentioned before, define('MULTISITE', true); is expected too.
(what solved it for me) Setting up multi-site for wordpress, changed the 'wp_blogs' table's column 'path' to an undefined location for my website. I changed it to "/" and the DB connection was re-established.
I added $base = '/'; into the config, which solved the issue.
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'mydomain.com');
$base = '/';
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
You need to add to your wp-config.php
:
define('MULTISITE', true);
I had the same problem. I skipped this line because I already had define('WP_ALLOW_MULTISITE', true);
in my wp-config and it looked to me the same.
If you're running WHM/cPanel and you've already checked that you've added the MULTISITE
/WP_ALLOW_MULTISITE
constant, you're probably running into virtual host issues.
If you're getting the database error, chances are, your name servers or A record is correct. Otherwise your domain wouldn't be pointing to your server with a database connection. But, you've probably forgotten, or missed, the domain name from the cPanel aliases.
Just head to cPanel, search for 'Aliases' and type in the domain name you're missing under 'Create a New Alias'.
You can also get to cPanel by logging into WHM, searching for 'List Accounts', searching for the account you want and clicking on the CP icon.