Converting to Multisite - DB Connection Error, Tables Missing

When adding the following lines to /config/application.php in order to convert an existing Bedrock install to multisite I receive an db connection error due to missing tables. I’m sure it’s an RTFM situation that’s not Bedrock related but could someone point me in the right direction as to how to convert to multisite and/or get missing tables and their structures in the db properly? Thanks in advance!

config/application.php:

/**
 * Multisite Network
 */
define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', env('DOMAIN_CURRENT_SITE') ?: parse_url(WP_HOME,  PHP_URL_HOST));
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

DB Connection Error:

Error establishing a 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.

Database tables are missing. This means that MySQL is not running, WordPress was not installed properly, or someone deleted wp_site. You really should look at your database now.

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

Doesn’t this error mean PHP literally cannot connect to the database, not just that it did not find the correct tables?

Thanks for the reply @kalenjohnson. That must be what’s happening but as soon as I disable #multisite all connects just fine—so at least I know it’s not the credentials. I’m assuming that when you enable multisite on any ol’ WP install then core adds those missing tables?

Well I’m confused as to why but it’s working now so far. So for others that may run into this issue here’s what I’ve done so far to fix it. I think it was local dev server situation and not sure in what capacity.

I did two things but when I set each setting back to the way they were it still works. So… wtf.

  1. Commented out some lines in ~/.bash_profile that are used to allow WP-CLI to work with MAMP (PHP version will vary of course):
# Use MAMP version of PHP
#PHP_VERSION=ls /Applications/MAMP/bin/php/ | sort -n | tail -1
#export PATH=/Applications/MAMP/bin/php/php7.0.20/bin:$PATH
  1. In your MAMP Pro (v 4.x) settings for the host under the Databases tab, map the host entry to your WP database and restart the servers.

Hope this helps someone else out and if anyone has some thoughts here as to why toggling either or both of these would spank this into allowing WP to create the tables it needed for multisite with MAMP. I can only assume it’s permissions based?

Ugh, okay, more to report. I know this didn’t do the trick prior to toggling the aforementioned settings/configurations with MAMP Pro and ~/.bash_profile but now I get the connection/missing tables error again if either or both of the two commented out lines below in /config/application.php are used:

/**
 * Multisite Network
 */
define('WP_ALLOW_MULTISITE', true);
// define('MULTISITE', true);
// define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', env('DOMAIN_CURRENT_SITE') ?: parse_url(WP_HOME, PHP_URL_HOST));
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

MAMP…:see_no_evil:

If you don’t want to use Trellis or a VM, Valet is a lot better than MAMP

I need to read these again. Went down MAMP alternative routes (including Valet, Trellis and VVV) and the ONE thing we could not get to work was having other users/employees on our network point to sites via their hosts file… then we gave up, hung our heads and texted MAMP our shameful booty call. :pensive:

Related topic: Allowing for other machines on network to point to host machine that's using Trellis

Multisite with Bedrock and MAMP Pro Working! :grinning:

In other news here’s how in full I have my MAMP Pro multisite set up working—hopefully this is helpful to others down the road!

/config/application.php

/**
 * Multisite Network
 */
define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', env('DOMAIN_CURRENT_SITE') ?: parse_url(WP_HOME, PHP_URL_HOST));
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']); // for mapping other domains to sub sites (pointed new MAMP Pro hosts to same doc root

/web/.htaccess

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L]
RewriteRule ^(.*\.php)$ wp/$1 [L]
RewriteRule . index.php [L]

Note: after getting this working the rewrites make the WP Admin path /wp/wp-admin set back to /wp-admin/. Still wondering if my rewrites aren’t quite right and/or if once of the env vars in /.env should be updated?