WordPress is a dynamic content management system (CMS), meaning all the content, settings, and configurations of a WordPress site are stored in a MySQL (or MariaDB) database. The PHP-based WordPress core interacts with this database to retrieve, display, and update information whenever a visitor loads the website.
What the Database Stores
The database holds almost everything about your site, including:
- Content: Posts, pages, custom post types, revisions, drafts
- Users: Usernames, passwords (hashed), roles, permissions
- Settings: Site URL, theme options, plugin configurations
- Media: File references (images, videos, docs โ though the files themselves are stored on the server, their paths and metadata are stored in the DB)
- Comments: Comment text, author info, approval status
- Taxonomies: Categories, tags, and custom taxonomies
- Links & Metadata: Post meta, user meta, term meta
The Default WordPress Database Tables
By default, a fresh WordPress installation creates 12 core tables. Each table has a specific purpose:
1. wp_posts
This is the core table of WordPress. It stores posts, pages, custom post types, attachments, and revisions. Almost all site content lives here.
Columns:
IDโ Unique identifier for each post (Primary Key)post_authorโ ID of the user who created the post (reference towp_users.ID)post_dateโ Date and time when the post was createdpost_date_gmtโ Same as above, in GMTpost_contentโ Main content of the post/pagepost_titleโ Title of the postpost_excerptโ Short summary or excerptpost_statusโ Status (e.g., publish, draft, trash)comment_statusโ Whether comments are allowed (open/closed)ping_statusโ Whether pingbacks/trackbacks are allowedpost_passwordโ Password for password-protected postspost_nameโ URL-friendly slugto_pingโ Sites to pingpingedโ Sites that have been pingedpost_modifiedโ Last modified date/timepost_modified_gmtโ Last modified date/time in GMTpost_content_filteredโ Used internally for filtered contentpost_parentโ ID of parent post (for page hierarchy, attachments)guidโ Unique reference link (often used for media attachments)menu_orderโ Order of pages in menuspost_typeโ Type (post, page, attachment, nav_menu_item, custom)post_mime_typeโ MIME type (for attachments, e.g., image/jpeg)comment_countโ Number of comments related to the post
2. wp_postmeta
Stores extra information (metadata) about posts, often used by themes and plugins.
Columns:
meta_idโ Unique identifier for each rowpost_idโ Related post ID (wp_posts.ID)meta_keyโ The key (e.g.,_thumbnail_id,_yoast_wpseo_title)meta_valueโ The value for the key
3. wp_users
Stores information about registered users.
Columns:
IDโ Unique user ID (Primary Key)user_loginโ Username for loginuser_passโ Password (hashed)user_nicenameโ URL-friendly nameuser_emailโ Userโs emailuser_urlโ Userโs websiteuser_registeredโ Registration dateuser_activation_keyโ Key for account activation/password resetuser_statusโ Not commonly used (historical)display_nameโ Name displayed publicly
4. wp_usermeta
Stores metadata for users (roles, preferences, custom fields).
Columns:
umeta_idโ Unique row IDuser_idโ ID of the user (wp_users.ID)meta_keyโ Key (e.g.,wp_capabilities,wp_user_level)meta_valueโ Value for the key (often serialized arrays)
5. wp_comments
Stores all comments left on posts/pages.
Columns:
comment_IDโ Unique ID for each commentcomment_post_IDโ ID of the post the comment belongs tocomment_authorโ Name of the commentercomment_author_emailโ Email address of commentercomment_author_urlโ Website of commentercomment_author_IPโ IP address of commentercomment_dateโ Date/time of commentcomment_date_gmtโ Date/time in GMTcomment_contentโ The actual comment textcomment_karmaโ Used for rating (not widely used)comment_approvedโ Approval status (1, 0, spam)comment_agentโ User agent string (browser info)comment_typeโ Type (comment, pingback, trackback)comment_parentโ ID of parent comment (for nested replies)user_idโ ID of registered user (if commenter is logged in)
6. wp_commentmeta
Stores metadata for comments.
Columns:
meta_idโ Unique row IDcomment_idโ ID of the comment (wp_comments.comment_ID)meta_keyโ Metadata key (e.g.,_akismet_result)meta_valueโ Metadata value
7. wp_terms
Stores terms used for categories, tags, and custom taxonomies.
Columns:
term_idโ Unique ID for the termnameโ Human-readable name (e.g., "Technology")slugโ URL-friendly nameterm_groupโ Groups terms (rarely used)
8. wp_termmeta
Stores metadata for terms (extra info about categories/tags).
Columns:
meta_idโ Unique row IDterm_idโ ID of the term (wp_terms.term_id)meta_keyโ Metadata keymeta_valueโ Metadata value
9. wp_term_taxonomy
Defines the taxonomy of a term (category, tag, or custom).
Columns:
term_taxonomy_idโ Unique IDterm_idโ ID of the term (wp_terms)taxonomyโ Type (category, post_tag, custom)descriptionโ Description of the termparentโ Parent ID (for hierarchical taxonomies)countโ Number of posts linked to this term
10. wp_term_relationships
Maps posts to terms.
Columns:
object_idโ The ID of the object (usuallywp_posts.ID)term_taxonomy_idโ ID fromwp_term_taxonomyterm_orderโ Ordering (rarely used)
11. wp_options
Stores site-wide settings and plugin/theme configurations.
Columns:
option_idโ Unique IDoption_nameโ Name of the option (e.g.,siteurl,home)option_valueโ Value of the option (often serialized arrays)autoloadโ Whether to autoload option (yes/no)
12. wp_links
Stores blogroll links (legacy feature). Still present for compatibility.
Columns:
link_idโ Unique IDlink_urlโ URL of the linklink_nameโ Name of the linklink_imageโ Related image URLlink_targetโ Target attribute (_blank, _top)link_descriptionโ Description textlink_visibleโ Visibility (Y/N)link_ownerโ User ID of link creatorlink_ratingโ Rating (0โ10)link_updatedโ Last updated datelink_relโ Relationship valuelink_notesโ Notes about the linklink_rssโ RSS feed for the link

How WordPress Uses the Database
When a visitor opens your site:
- WordPress connects to the database using credentials in
wp-config.php(DB_NAME,DB_USER,DB_PASSWORD,DB_HOST). - It runs SQL queries to fetch content (e.g., fetching post content from
wp_posts). - PHP processes the query results.
- The theme (HTML + CSS) displays it in a user-friendly format.
Example Query:
SELECT * FROM wp_posts WHERE post_status = 'publish' AND post_type = 'post';
This fetches all published blog posts.
4. Common Database Operations
- Create โ Adding a new post, page, or user inserts data into tables
- Read โ Loading a page fetches data from
wp_posts,wp_options, etc. - Update โ Editing content updates existing rows
- Delete โ Removing content deletes rows or marks them as trash
5. Database Optimization & Maintenance
Since WordPress constantly interacts with the database, optimization ensures speed and security.
Best Practices
- Regularly clean up unused data (spam comments, revisions)
- Use a caching plugin (reduces database queries)
- Optimize tables with SQL or plugins like WP-Optimize
- Backup the database frequently
- Secure database access (strong passwords, change default
wp_prefix)
6. Plugins & Custom Tables
Many plugins create their own tables to store data.
Example: WooCommerce creates tables for orders, products, and customers. Developers can also create custom tables for advanced needs.
7. Visualizing the Database Flow
Imagine the database as the heart of WordPress:
- Posts/Pages โ Stored in
wp_posts - Settings โ Stored in
wp_options - Users โ Stored in
wp_users - Plugins/Themes โ Store settings in
wp_optionsor custom tables - Categories/Tags โ Stored in
wp_termsand linked viawp_term_relationships
Every request โ Goes through SQL โ Processed by PHP โ Displayed via theme
In Summary
The WordPress database is a structured storage system that powers everything from posts and settings to users and plugins. Understanding its structure helps in troubleshooting, optimization, and advanced customization.

Gokila Manickam
Senior WebCoder
Gokila Manickam is a Senior WebCoder at FUEiNT, contributing expert insights on technology, development, and digital strategy.
