If you've worked with WordPress and WordPress Multisite long enough, you've probably had the realization at some point that the database is where the magic happens; it's what makes WordPress Multisite (WPMS) the powerful content management system that it is. When working with WPMS specifically, the database gets predictably more complex than that of a standard WordPress site as you add tables that deal with the multisite functionality as well as tables for each of your subsites.
While it may be overwhelming to consider the database of your WPMS, and looking through it can feel like diving into a cryptic, forbidding world, having a basic understanding of and confidence in your WPMS database can dramatically improve your admin experience.
Find your database in phpMyAdmin
phpMyAdmin is how Reclaim Hosting provides administration access to MySQL and MariaDB databases. This open source tool allows you to easily access and manage your databases and tables at once.
WPMS in cPanel
If your WPMS is set up in a cPanel environment, follow these instructions:
Before you can find your database in phpMyAdmin, you'll need to know which database to look for. Identify your WPMS database by going to the MyApps area of your cPanel, clicking on your multisite's title, selecting the Files & Tables tab, then scrolling down to the second section in that tab where you'll see the database table shown.
In the example from these screenshots, our WPMS database table name is the username followed by "_wp3". The number that comes after the "_wp" is the important part; make a note of that number before moving on.
Now that you have your database table name in mind, go to phpMyAdmin by scrolling down the to Databases section in cPanel and selecting phpMyAdmin.
Once you're popped into the phpMyAdmin interface, navigate to the database you want to work with on the lefthand sidebar.
WPMS in Reclaim Cloud
If you're set up on Reclaim Cloud without a cPanel interface, follow these instructions:
To find your database credentials, go to the Config section of your WPMS environment.
Once in your Config area, navigate to
/var/www/webroot/ROOT/wp-config.php to access your wp-config.php file. This file will have the credentials you'll need to log into phpMyAdmin to access your database; while in a cPanel interface this is all integrated for you, in a container environment like Reclaim Cloud we just have to grab that info ourselves.
Once in the wp-config.php file, scroll down until you see the values next to 'DB_USER' and 'DB_PASSWORD'. Keep these credentials on hand so you can copy and paste them in the next step.
Now we'll navigate to phpMyAdmin. Open a new tab in your browser and go to https://your-environment-name.com:8443.
On this page you should see the phpMyAdmin login screen, where you'll input those credentials form your wp-config.php file.
Once you're in phpMyAdmin, you should be able to easily find your WPMS's corresponding database, as this method spins up a phpMyAdmin instance that is specific to your environment.
Navigating your database tables
You may be accustomed to the typical WordPress database structure where there are a variety of tables related to a single site; WPMS expands on this, and there are a few things you should know about how to navigate in this particular database setup.
Tables are organized by subsite ID
If you're troubleshooting a specific subsite for your WPMS in the database, you'll want to be sure to grab the subsite's ID, since that will be the way you identify the tables associated with that subsite.
Find your subsite's ID by going to your WPMS Network dashboard then following the My Sites dropdown to Network Admin to Sites.
Then, hover your mouse over the site you'd like to work on and check the lower left-hand area of your browser to find that subsite's specific ID. A small bar will pop up with the ID listed last.
So, the subsite I want to work with here— wpms.amanda-wentworth-schmidt.com/the1975— has the ID 2.
Back in phpMyAdmin, I'll be able to find the tables associated with this subsite by looking at the ones that follow the convention wp_2_table-name.
A key table: wp_options
Most of the work you'll likely be interested in doing in your WPMS database will take place in the wp_options table.
A few rows you'll find particularly useful when troubleshooting various scenarios include siteurl, home, template, stylesheet, and active_plugins.
Siteurl & home
The siteurl and home option names should match each other and the URL listed in WordPress Address (URL) and Site Address (URL) under the site's general settings. If one of your subsite users does something like tries to change their site's WordPress Address and/or Site Address to something other than their assigned domain name, their site will break. By going into these rows in the wp_options table, you can change the URL back to their actual domain name to fix the problem, as outlined in our guide Fix for Changing Site URL in WordPress.
Template & stylesheet
The template and stylesheet option names refer to the theme running on your site. It can be helpful to see the active theme in a subsite's wp_options table when a site is down, often due to a theme incompatibility or bug, as you can simply change a problematic theme to another theme that's available on the user's site. The twentytwentytwo theme shown in the above screenshot is a great, safe theme to swap for a potentially problematic theme to rule out that kind of incompatibility when troubleshooting, especially when the issue keeps you from accessing the user's dashboard.
The active_plugins option name can look... strange. But it is parse-able, especially if you're simply looking for the name of the plugins currently active on a user's subsite. Not only can this be helpful for troubleshooting, such as when you know that a certain plugin is causing issues and you need to see which users have it active, but it can also help you do a relatively quick assessment of the active plugins network-wide.
The world of WPMS is your oyster when you have a solid grasp of the database! It helps you troubleshoot, quickly assess what's going on in each site, and can even help you write your own PHP functions if you're so inclined. Hopefully this article gives you some ideas for how to jump in.