What Is a Database and Why Does WordPress Need One?

Share on facebook
Share on twitter
Share on email

Novice site owners often ask, what is a database and why does WordPress need one? You can think of your WP database (DB) as a massive computer-generated filing cabinet. A little appreciation of the DB system is sure to give you more respect for your precious web content.

This short tutorial answers these 6 WP database questions:

  1. What is a WordPress database exactly?
  2. Why does your WordPress website need a database?
  3. What is a DB host?
  4. What is a DB table?
  5. What is an SQL Query?
  6. How do you manage your WordPress DB?

It looks technical, but understanding the basics is easier than it sounds.

#1 What is a WordPress database exactly?

A WordPress website requires data to function. Data—in this context—refers to individual or sets of items stored in a centralised database. Thus, a database is a well-organised collection of critical data kept in tables and organised into columns and rows. The WP database holds your site’s configuration settings, usernames, passwords, posts, pages, comments, and themes, etc.

A WordPress database has the following four parts:

  1. The database name, e.g., MySiteDB
  2. Table names, e.g., wp_users, wp_posts, wp_links, etc.
  3. Table column names, e.g., ID, user-login, and user-pass, etc.
  4. Rows to accommodate multiple columns

#2 Why do WP websites need a database?

There are two parts to every WordPress blog or Website, i.e., files and database. Files cannot load correctly without the required data. When you create a new WP page or post, it auto-grabs essential information from the database via programming. If the stored data changes, the post or page changes with it—automatically.

The WP DB ensures your site is current and runs smoothly behind the scenes. Moreover, the organised data stored in a centralised database makes backups quick and tidy.

#3 What is a MySQL database host?

WordPress uses a MySQL server, which is special software for managing the database and connecting it to the website. The local computer that hosts your DB on a MySQL server is your database host. Most database hosts are aptly named localhost, or the loopback address, in computer terms. You can also look at the local host to mean ‘this computer.’

#4 What is a DB table?

Every WP database consists of tables, many of which have multiple columns that form rows. Database table names are hyperlinked. Clicking the names opens the table to reveal the data stored in organised columns along a single row. Here’s how that looks for the wp-users table:

By default, WordPress creates tables inside its databases with the wp_ prefix.

A typical default database installation includes the following tables:

  • wp_commentmeta
  • wp_comments
  • wp_links
  • wp_options
  • wp_postmeta
  • wp_posts
  • wp_term_relationships
  • wp_term_taxonomy
  • wp_terms
  • wp_usermeta
  • wp_users

Anything you add to your WP site afterwards gets added to the database. That typically includes new tables for installed plugins, themes, and any custom programs.

#5 What is an SQL Query?

Structured Query Language, aka SQL, is a programming language used to control database management. SQL sends instructions to your database server when it needs to retrieve, update, insert, and delete data. We call these instructions SQL statements and the process an SQL Query. All Queries have unique, recognisable names, e.g., CREATE, ALTER, DELETE, etc.

Here are 4 examples of commonly used MySQL Queries (names in bold).

SQL Statement

SQL Query Description

CREATE DATABASE database

Creates a new database

ALTER TABLE table change

Changes the table schema (data organisation)

DELETE FROM tablename WHERE clause

Deletes data from table

CREATE TABLE (col def,. . .,PRIMARY KEY(col))

Creates a table

#6 How to manage a WordPress Database?

Every WordPress site owner should know how to back up their WP database. You can do regular backups manually or use a plugin to email automated backups to you.

Here’s a screenshot of an automated DB Backup emailed to a Gmail account.

Database management skills are also useful for the following tasks:

  • Recover your blog, website, or internet store
  • Troubleshoot issues
  • Enhance site security

WordPress users manage databases using phpMyAdmin, accessible from cPanel (control panel). It’s a free, open-source software tool for working with MySQL and MariaDB over the web.

From your cPanel account, click phpMyAdmin from the DATABASES section.

The phpMyAdmin interface is user-friendly. Despite that, it’s no place for the inexperienced. Always back up the DB before working in here, and only if you know what you’re doing.

Below: Top section of a typical phpMyAdmin screen.

Closing Comments

You now understand what a WordPress database management system is, why it’s vital, and how to access it. At the basic level, site administrators should back up their DB regularly. Only change WordPress options or try to find and fix issues from phpMyAdmin if you know what you’re doing. 

Share on facebook
Share on twitter
Share on email

Subscribe to my newsletter

Subscribers to my newsletter get all the latest news, reviews, advice and gossip in the world of search engines, internet marketing, self-publishing, and North Wales (where I live). You can sign up for my free newsletter by clicking this link.

My Books

I have a range of webmaster related books for sale on Amazon in both Kindle and Paperback formats. WordPress, SEO & Self-Publishing.
On Amazon

My Online Courses

My courses cover a range of webmaster related skills, from learning WordPress itself, to installing an SSL certificate on your site.
On Udemy

Comments

Hello, I'm
Andy Williams!

You can get up to 90% off my Online Courses for webmasters, marketers & affiliates (plus a free course on Gutenberg).

Get my newsletter
delivered to your inbox

18748

We respect your privacy

18749