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:
- What is a WordPress database exactly?
- Why does your WordPress website need a database?
- What is a DB host?
- What is a DB table?
- What is an SQL Query?
- 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:
- The database name, e.g., MySiteDB
- Table names, e.g., wp_users, wp_posts, wp_links, etc.
- Table column names, e.g., ID, user-login, and user-pass, etc.
- 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:
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 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.
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.