|

To the casual WordPress user, a website can be created and updated quite easily using WordPress as the content management system (CMS). What this same user does not see is that behind the magic that happens in WordPress is a database that stores and powers all of the content and settings that allows the site to run. WordPress databases exist to store all of the content for your website, but they’re much more than that. The settings are numerous, but they all have one goal in mind: to help you do things on your WordPress site like create posts and pages, approve comments, send email alerts, and so on.

Furthermore, a WordPress database is used to store your website’s theme and plugin configuration settings. If you’re searching for methods to increase your site’s loading speed or troubleshooting an issue with your site, learning how WordPress databases function can be quite beneficial.

Why Your WordPress Site Needs a Database

In general, every WordPress website has a wide range of data to store. All of this information must be kept somewhere. The WordPress database is where you’ll find it.

WordPress isn’t the only platform to feature a database system. A database can be basic or advanced, and it can be big or small. Databases keep data in a specific format meant to be stored and read by an application.

The following are examples of the types of data kept in WordPress’s database:

  • Your site’s settings
  • Posts, pages and comments
  • User profile data
  • Data for your plug-ins and themes
  • Categories, tags

How the WordPress Database Works

When you set up WordPress to build a new website, it creates a database. The most common scenario is for the database to be automatically created during WordPress installations. However, it is also feasible to manually create a database or utilize a pre-existing one. Your new database will be stored on the server of your hosting provider, regardless of whether it was generated automatically or manually.

When someone visits your website, their browser sends a request to your site’s server. The server responds with the necessary information so that your site may be properly displayed and function as planned for your visitors.

All databases need software to operate. MySQL, an open-source program, is the database software WordPress uses. This software is what allows your database to store your website’s information.

WordPress issues a MySQL command to your database when you need to store, delete, or change data.

WordPress Database vs. Files

The WordPress database is part of the hosting account and may be viewed directly through your hosting portal. The standard database tool to administer WordPress databases is called phpMyAdmin.

On the other hand, WordPress files are stored on a server’s file system. The server from your hosting provider is usually located in “the Cloud” nowadays, which is simply a network of interconnected servers.

In the same way that your computer files and software are stored on internal hard drives, WordPress website files are kept on servers so that they may fulfill the different demands for content and design that come together to create a full website experience for visitors.

Each of the code files has a role in terms of executing commands and providing information to the end-user, whether you’re administering your own server at home or it’s being handled by a hosting firm.

The files of your WordPress site will include theme files, plugin files, images you upload, and documents you upload. The database on the other hand, stores the stuff that is “not-files”. This “anti-file” if you will, would be the content you type into the website, anytime you go into the website and you change a setting like a post category. 

Even the settings that you set up when you first set up a theme or a plugin are stored in the database. When you perform an action on your computer it isn’t a file, it is an “anti-file” or an action. That action is recorded in the database.

How to Access WordPress Database

The majority of your WordPress database is self-sufficient. For example, you won’t have to log into the database all the time to operate your site or create/edit site content. Nevertheless, there are times when knowing how to get and understand what’s in your database is critical.

You might want to access your WordPress database for the following reasons:

  1. Plugins with a “Live” Preview feature might seem broken and the only way to fix them is to view the information on your website’s backend by logging into your WordPress site.

(Note: This can be just an issue with some plugins, please check for support forums of that plugin before saying WordPress is down.)

  1. You can check if your website is down by viewing PHP errors so you will know the error codes and the message displayed on your website’s backend.

(Note: You can also view these errors in your hosting control panel so this might not be a case of WordPress being down.)

  1. If you are just curious about how WordPress works, there is nothing wrong with that.
  2. You can check website statistics such as traffic, visitors, and referrers which will help you understand the performance of your website. (Note: Please see this link for more accurate ways to analyze your site’s traffic.)

(Note: You can also check these statistics in your hosting control panel so again this might not be a case of WordPress being down.)

  1. If you are just curious about how website statistics work, there is nothing wrong with that.
  2. You can temporarily “Disable” your WordPress site to show a different message than what is displayed on public and 404 pages. (Note: Use this feature with caution as it might cause confusion and frustrate users.)
  3. For security purposes, you can have a peek at your website’s backend to see what hackers might be trying to do.

Remember that we previously said that your WordPress database is hosted on the server for your site. As a result, you’ll need to use your hosting provider’s tools to access it.

Depending on the hosting provider you’re using, accessing the database may be a little different. However, in most situations, you’ll use a program called phpMyAdmin to access it.

PHPMyAdmin is a free program that allows you to manage your website’s MySQL database. Once you log in to your web hosting dashboard, you will see an option to open phpMyAdmin. Open it and a login screen will appear for you to input your database username and password.

How to Access WordPress Files?

Now that you know where WordPress files are located, how do you access them when you want to modify your website design, organize media items and upload new themes?

Here are the many choices for accessing and viewing and managing your WordPress files:

Through web host’s portal (or cPanel)

Web hosting companies usually provide a control panel for its customers. The most common ones are called cPanel and Plesk, where you can find a file manager tool that allows you to access your website files through an online interface.

Using a File Transfer Protocol (FTP) Client

Perhaps the most common way to access WordPress files is by using an FTP client.

There are tons of free and paid FTP client programs you can use, which allow you to upload, download, manage and edit WordPress files through a visual interface.

Accessing files locally

If your website sits on your computer’s hard drive, then the easiest way to manage WordPress files is by accessing them locally.

You can use the file management tools of your operating system to access local directories, folders and files.

Through the WordPress Admin Dashboard

You can use the WordPress Admin Dashboard to upload new themes and plugins directly, which is typically preferred over manipulating plugins and themes via FTP.

The WordPress file manager isn’t really for accessing and modifying existing theme files (it is mostly used for uploading new ones), but it does allow you to access other types of files like images and documents through the Media Library.

Case Study

In the case where we have a website that was staged into a staging environment (certain web hosts like WPEngine offer this), we have to be aware of changes made to the database in staging vs production (the live site). Copying the staging site with it’s database to live will completely overwrite any new changes to the live database since the staging copy of the site was created. 

If your site was staged for a super long time and someone has since changed a bunch of stuff on the live site, then you probably do not want to push tables from staging to live. In that case, if it’s only files you have updated in staging, you can push files to live without copying the database, as well. Remember, anything that was changed on live after you staged the site will be erased if you copy the database.

The downside, however, if you don’t copy the database is that if you made changes to the database on staging, those changes won’t carry over. So you would need to redo them. Another important thing to keep in mind is sites that have eCommerce or reservation/purchase/ticketing systems. When you stage those sites, if you keep it staged for any length of time and there is a purchase on the live website since it was staged, then pushing datatables when you deploy, will overwrite the purchases. If you get into a situation where this is happening often, then we should talk about a strategy and use of development environments in which you are able to stage and make updates to your site safely without overwriting any work.