WordPress Database: What It Is, How to Manage It, and Best Practices

WordPress Database: What It Is, How to Manage It, and Best Practices

A WordPress database stores all the data that makes up a WordPress website, including login credentials, pages, posts, themes, and plugins.

Basic knowledge of databases helps you understand how the platform works and troubleshoot errors more efficiently. It also enables you to perform tasks inaccessible through the WordPress dashboard, such as changing usernames.

In this article, we’ll explain what a WordPress database is and why it’s important. We’ll also show how you can access and manage it.

A WordPress database is a storage of your website data that uses the MySQL database management system. All WordPress databases have a default MySQL structure, which enables your website to function properly.

How a WordPress Database Works

When installing WordPress for the first time, you’ll also create a database to contain the core tables. It is usually stored on your web host server, often referred to as a database host.

A database management system (DBMS) is then used to control and manage it. This software splits complex data into smaller parts to organize them better.

DBMS works similarly to saving files and folders on a computer drive. Each folder contains specific file categories. This enables users to locate, modify, and delete any desired data easily.

An illustration of how DBMS works.

WordPress uses MySQL as its management system. MySQL uses the Structured Query Language to create, read, update, and delete data from a database.

While most MySQL queries run automatically, users can also perform them manually to change WordPress URLs and carry out other tasks.

What Is a WordPress Database Host?

A host is a server that stores a database. Usually, a website and its database are hosted on the same server. As a result, localhost is the typical hostname used to manage and connect a WordPress site to the database.

WordPress users can also use MySQL remote connection to connect their database to a remote server. In Hostinger, simply access Remote MySQL in hPanel. Note that a Hostinger hostname is required to enable the remote connection.

Remote MySQL section on hPanel

What Is a WordPress Database Table?

A database stores data in the form of tables. Each table consists of unique data displayed in columns and rows that contain more specific pieces of information or parameters.

By default, a WordPress database contains the following tables;

  1. wp_commentmeta – keeps the metadata of each comment posted on the website.
  2. wp_comments – stores data related to user comments, including the author name, URL, IP address, email, and comment content.
  3. wp_links – it was used for holding information from the Links feature. Since the feature has been deprecated, this table is often empty.
  4. wp_options – contains WordPress configuration settings, such as website URL, default category, and posts per page.
  5. wp_postmeta – keeps metadata of each post on the site, such as custom fields.
  6. wp_posts – stores data from articles, custom post types, pages, and navigation menu items.
  7. wp_termmeta – stores metadata of the terms.
  8. wp_terms – contains the WordPress terms for each post tag and category.
  9. wp_term_relationships – maintains the association between posts and terms in the wp_terms table.
  10. wp_term_taxonomy – describes the taxonomy for each category, link, and tag in the wp_terms table.
  11. wp_usermeta – keeps the metadata of each registered user on a WordPress site.
  12. wp_users – contains the list of users, including their usernames, passwords, and email accounts.

Each table stores specific data about your site. When you make website changes, the data on these tables can add and pile up. That’s why you should learn how to access and optimize your WordPress databases.

How to Access a WordPress Database

When setting up the platform manually, you’ll have to create a brand new WordPress database. To speed up the process, consider looking for a hosting provider with automatic installation.

Our WordPress hosting plans let you install WordPress in just a few clicks.

After the installation, access the database directly via your control panel, the hPanel:

  1. Go to Hosting -> Manage.
  2. Scroll down to the Databases section.
  3. Select MySQL Databases to view and create databases and users.
The list of current databases and users in hPanel
  1. Click Enter phpMyAdmin to access the database.

Alternatively, access phpMyAdmin using our unique direct link:

  1. Open Databases -> phpMyAdmin.
  2. Click on the link at the top of the screen.
phpMyAdmin direct link on hPanel
  1. Once the login screen appears, fill in your MySQL database username and password.

How to Manage a WordPress Database?

After you click on the direct link or the Enter phpMyAdmin button, this interface will appear:

The phpMyAdmin interface showing default WordPress tables

Here, you can access the default WordPress database tables and perform basic management tasks, such as:

  • Running a MySQL query.
  • Creating and deleting tables.
  • Searching and sorting data based on specified criteria.
  • Inserting, editing, and deleting records, rows, and columns.

Remember that a database contains essential settings for your WordPress website. Thus, be careful not to remove any data accidentally.

As a precaution, we recommend creating a database backup:

  1. Choose the database source on the left pane.
  2. Go to the Export tab.
  3. Pick an export method – Quick or Custom. The first option lets you quickly download the backup file, while the latter gives more options when exporting.
  4. Select the database format – SQL is the most common.
  5. Click Go.
Exporting a database table in phpMyAdmin

Your computer will then download and save the SQL files. To retrieve the database backup file, simply go to the Import tab, upload the correct file, and click Go.

Pro Tip

You can also use WordPress plugins to manage your database. Check out our list of the best WordPress database management plugins.

How to Optimize a WordPress Database

Database tables can become fragmented over time, creating memory overheads that affect the MySQL query speed. Fortunately, phpMyAdmin enables you to optimize the database:

  1. Go to Hosting -> Manage.
  2. Access Databases -> phpMyAdmin -> Enter phpMyAdmin.
  3. Under the Structure section, click on Check all -> Optimize table.
Optimizing database tables in phpMyAdmin.

This process will clean up some memory and boost database performance.

Other Helpful Database Tricks in hPanel

Apart from managing and optimizing a site’s database, hPanel also enables you to perform other database-related tasks.

Change the Current WordPress Database Password

Your database password needs to be updated regularly to improve your WordPress security. Here’s how:

  1. Go to Hosting -> Manage -> MySQL Databases.
  2. Click on the three dots to the right of the database name and select Change Password.
  3. Type in your new password and click Update.
MySQL database on hPanel: change password option

Change Permissions

By default, MySQL users have complete control over modifying a database. If you want to create a custom database with limited permissions, follow these steps:

  1. Click on the three dots and choose Change Permissions.
User permissions of the WordPress database in hPanel
  1. Unselect any permissions you wish to remove.
  2. Click Update.
The list of MySQL user permissions.

Delete a Database

If, for some reason, you need to remove a database, click on the options button and choose Delete.

Delete WordPress database via hPanel

Remember to create database backups before deleting them, as this action is irreversible.

Conclusion

Databases are an essential part of WordPress sites. They store data and files and ensure your website works well.

In this guide, we’ve explained what a WordPress database is, how it works, and its main components. We’ve also shown you how to access and manage your databases via hPanel and phpMyAdmin.

If you have any questions, please share them in the comment section below.

Author
The author

Luqmanul M.

Luqman is a self-proclaimed social scientist. He is passionate about education, technology, and everything in between. He wants to help create a high-quality education system. Having spent the past four years as a social researcher and blog guru, he lends his skills to Hostinger's digital content team. As for free time, he enjoys reading scientific (and not-so-scientific) literature with a cup of black arabica coffee as a companion.

Author
The Co-author

Brian Fajar Mauladhika

Brian is a Content Writer who knows the ins and outs of digital marketing and eCommerce. Driven by passion and a dose of caffeine, he constantly looks for better ways to tell complex stories in a simple manner. Follow him on LinkedIn.