Beginner’s Guide to WordPress Database Management with phpMyAdmin

WordPress is written using PHP as its scripting language and MySQL as its database management system. In order to use WordPress, you don’t really need to learn either of them. However, a very basic understanding of the two could help you troubleshoot problems as well as increase your understanding of how WordPress work. In this article, we will explain how WordPress uses the database including a primer on default WordPress database tables. We will also show you how to manage a WordPress database using phpMyAdmin which will include creating database backups, optimizing the WordPress database, and much more.

Video Tutorial

Subscribe to WPBeginner

If you don’t like the video or need more instructions, then continue reading.

How WordPress uses Database

WordPress uses PHP (programming language) to store and retrieve data from the database. The information stored in a WordPress database include: posts, pages, comments, categories, tags, custom fields, users, and other site options such as site urls etc. We will elaborate on this later in the tutorial when we cover all WordPress database tables.

When you first install WordPress, it asks you to provide your Database name, host, username, and password. This information is stored in the configuration file (wp-config.php).

During the installation, WordPress uses the information you provide about the database to create tables and store default installation data inside those tables. After the installation, WordPress runs queries to this database to dynamically generate HTML pages for your website or blog. This is what makes WordPress extremely powerful because you don’t have to create a new .html file for each page that you want to create. WordPress handles everything dynamically.

Understanding WordPress Database Tables

Each WordPress installation has 11 default tables in the database. Each database table contains data for different sections, features, and functionality of WordPress. Looking at the structure of these tables, you can easily understand where different parts of your website are stored. Currently, a default WordPress installation creates the following tables:

Note:wp_ before each table name is the database prefix you choose during the installation. It can be different.

wp_commentmeta : This table contains meta information about comments posted on a WordPress website. This table has four fields meta_id, comment_id, meta_key, and meta_value. Each meta_id is related to a comment_id. One example of comment meta information stored is the status of comment (approved, pending, trash, etc).

wp_links : To manage blogrolls create by earlier versions of WordPress or the Link Manager plugin.

wp_options : This table contains most of your WordPress site wide settings such as: site url, admin email, default category, posts per page, time format, and much much more. The options table is also used by numerous WordPress plugins to store plugin settings.

wp_postmeta : This table contains meta information about your WordPress posts, pages, and custom post types. Example of post meta information would be which template to use to display a page, custom fields, etc. Some plugins would also use this table to store plugin data such as WordPress SEO information.

wp_posts : The name says posts but actually this table contains all post types or should we say content types. This table contains all your posts, pages, revisions, and custom post types.

wp_terms : WordPress has a powerful taxonomy system that allows you to organize your content. Individual taxonomy items are called terms and they are stored in this table. Example, your WordPress categories and tags are taxonomies, and each category and tag inside them is a term.

wp_term_relationships : This table manages relationship of WordPress post types with terms in wp_terms table. For example this is the table that helps WordPress determine post X is in Y category.

wp_term_taxonomy : This table defines taxonomies for terms defined in wp_terms table. For example if you have a term “WordPress Tutorials“, then this table contains the data that says it is associated with a taxonomy categories. In short this table has the data that helps WordPress differentiate between which term is a category, which is a tag, etc.

Managing WordPress Database using phpMyAdmin

phpMyAdmin is an open source software that provides a web based graphical user interface to manage your mySQL database. Most WordPress hosting providers have phpMyAdmin installed in their control panel. This allows users to easily access the database and perform common database management tasks.

All of our recommended web hosting providers use cPanel. To access phpMyAdmin in cPanel, scroll down to Databases and click on phpMyAdmin. This will open phpMyAdmin in a new browser tab.

Clicking on Databases will show you a list of Databases you have created or have access to. Click on your WordPress Database, and it will show you the list of your WordPress Database tables.

Note: Before you change anything, you must make a database backup. There is no undo button. So just make the backup.

Creating a WordPress Database Backup using phpMyAdmin

To create a backup of your WordPress database from phpMyAdmin, click on your WordPress Database. On the top menu, click on the Export tab.

In newer versions of phpMyAdmin, it will ask you for a export method. The quick method will export your database in a .sql file. In custom method it will provide you with more options and ability to download backup in compressed zip or gzip archive. We recommend using custom method and choosing zip as the compression method. The custom method also allows you to exclude tables from the database. Lets say if you used a plugin that created a table inside your WordPress database, then you can choose to exclude that table from the backup if you want.

Your exported database file can be imported back into a different or the same database using phpMyAdmin’s import tab.

Creating a WordPress Backup using a Plugin

Keeping regular backups of your WordPress site is the best thing you can do for your WordPress security. While the WordPress database contains majority of your site information, it still lacks a fairly important element, images. All your images are stored in the uploads folder in your /wp-content/ directory. Even though the database has the information which image is attached where in the post, it is useless if the image folder doesn’t have those files.

Often beginners think that the database backup is all what they need. It is NOT true. You need to have a full site backup that includes your themes, plugins, and images. NO, most hosting company do not keep daily backups.

Note: If you are on a managed hosting solution like WPEngine, then you don’t have to worry. They take care of daily backups.

For majority of us who are not on WPEngine, you should use one of the many solutions available to keep regular backups of your site.

We are using VaultPress, a paid monthly service, to keep regular backups of our site. For those of you who love plugins and don’t like paying recurring fees, then we recommend that you check out BackupBuddy which is hands down the most complete backup solution for WordPress.

Optimizing your WordPress Database in phpMyAdmin

After using WordPress for a while your database becomes fragmented. There are memory overheads which increases your overall database size and query execution time. For those of us who remember in the old PC days, you would notice that your computer would get faster once you use Disk Defragmenter. The MySQL database works in a similar way. It comes with a simple command that allows you to optimize your database. Go to phpMyAdmin and click on your WordPress Database. This will show you a list of your WordPress tables. Click on Check All link below the tables. Next to it there is a “With Selected” drop down, click on it and choose Optimize table.

This will optimize your WordPress tables by defragmenting tables. It will make your WordPress queries run a little faster and slightly reduce the size of your database.

Other Things You can do Using phpMyAdmin

There are many things you can change in your WordPress website by changing values in Database using phpMyAdmin. However, it is highly recommended that you don’t ever do it unless it is absolutely necessary or if you know what you are doing. Make sure that you first back up your database before making any changes to your database. Below are some of the things you can do with your database:

Securing your WordPress Database

Before we get into this, we want to emphasize that every site can be hacked. However, there are certain measures you can take to make it a little harder. First thing that you can do to is to change WordPress database prefix. This can significantly reduce the chances of SQL injection attacks on your WordPress database because often hackers target sites in masses where they are targeting the default wp_ table prefix.

You should always choose a strong username and password for your MySQL. This will make it difficult for someone to get access to your database.

We hope that this guide helped improve your understanding of the WordPress database and how it works. While you may not need this guide right away, it always help to know how things work for the future.

87 Comments

I have two totally separate WP websites setup. Different domains, different databases. I manage both of them and they are both hosted on a dedicated server. I am trying to include some basic content that requires just a tad more than an RSS feed. I need to pull data from SITE-1 and display it on SITE-2

If it is a post or page you can go under Tools>Export on the site with the content to select the specific content you want to be transferred and then use Tools>Import on the site to bring in the content

I’m looking to create a website that would allow bands and venues to maintain their schedules, and a visitor to select a date and see all the bands playing on that date, and all the venues with bands playing on that date.
I’m proficient with the SQL (mySQL) needed to do the querying, just want to find out if WordPress will let me create custom pages based on the results of a query?
Thanks

I am new at a job and just taking over the website. However, I am reaching the Error Establishing Database Connection on the website itself and the login page. The email they used to originally sign up for the website has been deactivated due to her no longer working here. I have searched the files and cannot find the WP files I am seeing being mentioned above. I am unsure what my next steps should be. Any ideas?

How about for existing wordpress? just want to implement system that can be used by our staff only. i mean i want to create a page (basically a service report in our company website – wordpress) that can only be accessed by our staff

I recently created a few WordPress sites and I did it through one click WordPress installation in cPanel. What I wanted to know is, “Should I change my WordPress database name and database user name?” Is it something easily hackable if I’m already using a free security plugin like Wordfence?

Is it possible to get this information in an email rather than a tweet? It would be more easily accessible for me in an email for future reference. I appreciate all you do for newbies like me. Thank you.

Hello Sir, I have hosted my website with someone which has not given me inbuild features of myphp admin.So how to download it on my desktop plz guide .is there othere software required with myphp to download it.

i have a result table in database and i want to fetch the result of the student by registration number.
i m not getting solution to where to code in the wordpress site….and how to see result of the student by registration number.

Thank you so much for the tutorial, its powerful
however I have a question;

I have a database that I have created with workbench and I have imported it to phpmyadmin. however I want to connect with wordpress so that when I submit data through wordpress I can be able to view it in phpmyadmin and I can view it again in wordpress interface that I have created

based on a previous tutorial on installing wordpress on PC, I followed the tutorial and it was successful. i developed a website for diabetes association of Nigeria which iam a member too. But my challenge now is how to add registration form for new members to register online and how to get donation online in the website. i need your help please.

I use contact form 7 for feedback purposes and i store that data in database but now i want that particular data by URL like (abc.com/feedback/5) so it will show the data of id no 5 how i do this in wordpress?

I`m planing to make some wp website with registration for specific users ( I have a non profit organisation that has more than 2000 members.) Now, I have the list of them (members) in my Access db with all informations needed. My question is, is it possible to connect this access db with wp db? If yes, how to do that?
Also, every member has a unique ID in my db, which is also a number for the membership card they have. If before mentioned is possible, could I make a field in registration form, beside Username&Pass, that would request that ID number which would be checked from db and if correct, make a registration, if false, deny it?
Hope you understand me cause my englesh is not so grate…
Thanks in advance

Hello, I am preparing to launch my first wordpress blog site under my first website. Testing and learning the blog setup I am wondering how the email stuff is working. I created a comment in response to a post and ticked the email me a notification when posts are done option. And when I made another post I received an email notification. Looking in the tables using phpmyadmin I can see the email address I entered with the comment stored in wp1_comments but cannot see where/how the fact is stored that an email should be sent to that address when a new post is made.

Hello
I need some help, because I don’t understand something:
I register a WP website… and install WooCommerce in it. (I use XAMPP localhost on C partition)
So I have a clear WP+WooCommerce site which I’d like to use to create other WP sites too.
So I copy all the WP files from C… to another partition, let’s say D partition
and I also export its database by phpMyAdmin. Now I have a copy of the WP site and its database on D partition.
But what if I’d like to use the copied WP+WooCommerce site (pattern) I’ve created?
It is still contains the same e-mail address and password I used when I registrated on the official site of WP right? So how can I modify that?
I’d like to create a new website (with different admin e-mail and password) but using the same WP+WooCommerce site (pattern) I’ve created before.

Thank you for the great explanation of how WordPress interfaces to MySQL. Question: We have some blogs our site that are displaying a blank page. The blogs with blank pages have the same information as those that are working properly. I’ve used phpMyadmin to examine the tables and all looks well. Which table does WordPress use to begin the page generation?

The video was a little superfluous to the more descriptive written explanation of this article AND, as with many of your videos the narrator speaks too quickly and is thus difficult to understand if you don’t speak American. – even to me as a native English speaker!

phpMyAdmin is not a database management system. It is a utility that allows you to manage your database in a web based graphical user interface.

Your actual database resides on your MySQL database server. Any utility that wants to manage, backup, or make changes to your database will need your database username and password to do so.

BackupBuddy works as a WordPress plugin and your database username and password are already stored in your WordPress configuration file. So it can automatically connect to your database without explicitly asking for your username and password.

Thanks for the info. Is there a way to get the information from plugins (ie-contact forms) and put it into a local database like access..in order to increase data security? Does it have to be in the MySQL on the host? Thank you!

I made a back up of my SQL database on my computer with Export via PhpMyAdmin. Then, using a copy on that exported database, I made minor adjustments to some serialized links in the option table. Now I want to import the modified database back to the server with Import via PhpMyAdmin.
My question: before importing, do I have to make a drop of all the existing tables already there ?

If you want to create a web that contains say accommodations, address and name of university and need to store that data in database. Does WP provide database to store all of those datas, in text format, image and URL

It actually depends on the situation. If you used that plugin before and it has stored some important data that you would like to have then you should import it. However if you are just installing the plugin the first time then there is no need to worry about it the plugin will automatically create a new table for itself to use.

Question: when you create the database that will be used by wordpress, should you create a table as well or leave it? If you should create a table, then how many and why? What are the specifics for the/those table(s)?

Meaning; is it OK to create a database called wordpress and 1 table called mywp and then edit wp-config.php to contain this information plus the connection details for that database or should it be done differently?

Thanks for an interesting article. I hope you may be able to provide some direction.

I expect that I have some left over tables from plugins, but how can I find out what certain tables are? And how do I know which should be deleted or left alone? Would optimizing these tables fix them if they are my issue?

My reason for asking is that I have a small database for a new site build, but have slow sql queries and database connection errors.

These are my questionable tables

wrd_woocommerce_order_itemmeta (an old plugin that is no longer used)
wrd_woocommerce_order_items

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Notify me of followup comments via e-mail. You can also subscribe without commenting.

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).