WordPress Multisite “Error establishing a database connection”

When attempting to migrate or clone WordPress to a Multisite setup, some time get following error

Error establishing a database connection

Here’s How I fixed it

config settings

define( ‘MULTISITE’, true );
define( ‘SUBDOMAIN_INSTALL’, false );
define( ‘DOMAIN_CURRENT_SITE’, ‘localhost’ );
define( ‘PATH_CURRENT_SITE’, ‘/myblog/’ );
define( ‘SITE_ID_CURRENT_SITE’, 1 );
define( ‘BLOG_ID_CURRENT_SITE’, 1 );
Then in the database table (found using phpmyadmin) wp_blogs set the values for your root blog (which should be lie/number (1) to

domain localhost
root /myblog/
And finally – reset the sitrurl and homepage in options table (again found using phpmyadmin) to

http://localhost/myblog/

 

If you are still redirecting admin section to old site then check htaccess file.

Was this article helpful to you? Yes 1 No