In this lesson, we will introduce you to phpMyAdmin.
When you build your WordPress site, write posts or create pages, you constantly interact
with the database.
What does that mean?
And how can you access this data?
Let's dive in.
Here are the lesson outcomes.
Understand the difference between your site's files and database, explore your site's database
using the phpMyAdmin UI, and get a basic understanding of the structure and tables.
So, what is a database?
Almost all the content that you and your visitors create on a WordPress site is stored
in a database.
Posts, pages, comments, taxonomies, theme customizations, user details, etc.
None of these is a standalone file.
Rather, they are written to and read from a database that WordPress created during the
installation.
Explaining how databases work is beyond the scope of this lesson, but it might be helpful
to think of them as sophisticated spreadsheets.
Each table consists of columns and rows.
Columns represent data keys, while rows represent the individual values.
For example, the table named wp_posts hold all your posts.
Every detail of every post is listed as a row in this table, divided into columns that
represent the relevant information.
The post title is listed under the post_title column, and the content is under post_content
and so forth.
Since the data in the database is stored and managed along with all other files on your
hosting provider's server, you can access it, browse around and even modify the data.
Something important to note.
The database is perhaps the most critical part of your site, and you should only modify
if you have sufficient knowledge.
Think of this lesson as a look, but don't touch introduction.
To view your database, you need database management software.
Most hosting companies offer a browser-based tool called phpMyAdmin, which we'll be using
throughout this lesson.
If you don't have access to your host's dashboard or prefer to explore the database via the WordPress
admin dashboard, you can use a plugin such as SQL Buddy, Advanced Database Cleaner or
WP phpMyAdmin.
Also, don't forget to deactivate and delete the plugin when you're done to avoid potential
problems.
To access phpMyAdmin, all depends on how your hosting provider has set up their dashboard,
but usually you will open up the cPanel, select databases and then phpMyAdmin.
If your hosting company uses a different management platform, check the documentation resources
to find how to access phpMyAdmin.
My hosting company, for example, provides quick access to the WordPress dashboard and
phpMyAdmin, so I will go ahead and click on phpMyAdmin.
Then, click on the database's name on the top-left menu, and what you will see are all the tables
that comprise your WordPress site.
If you have more than one database and the name doesn't give a hint to which site it
belongs, you can head back to the WordPress admin dashboard, navigate to Tools, click
on Site Health, select the Info tab, and then click on Database.
Locate the line "database name" and then return to phpMyAdmin.
Let's inspect two of the most important tables found in every WordPress database.
The wp_options table stores information about your site's settings.
Each row in the table represents a specific setting, including information about your active
theme and active plugins.
On the other hand, the wp_posts table stores your posts, pages, custom post types and attachments.
Each row in the table represents a single piece of content.
Let's first discuss wp_options and look at the two middle columns.
The option_name column stores the keys, for example siteurl, blogname, blogdescription,
admin_email, etc.
While the option_value column stores the respective values.
These correspond to the details you set in your general setting screen.
For example, siteurl is the web address that appears as WordPress address URL, blogdescription
is the site tagline, etc.
Next, we move on to wp_posts.
This table contains many more columns, yet each corresponds to a familiar UI element
in the post editor.
Here are a few examples.
The post_title column is where you'll see the titles of all your posts or attachments.
The post_status indicates if it's a draft or published, and if we scroll to the right,
the post_type column indicates if this is a post, page or other type of content.
And then lastly, guid, which stands for "Globly Unique Identifier" stores the post URL.
In conclusion, as mentioned in the beginning, the database is a critical part of your site,
and you should only modify it if you have sufficient knowledge.
If you want to optimize, clean or modify it, whether you use phpMyAdmin or a plugin, make
sure you know what you're doing and have a backup and recovery solution in place before
you start.
To learn more about all of this, visit the Beginner WordPress Developer Learning Pathway, specifically
the lesson titled "The WordPress Database".