Hosting Question? Find the Solution - Browse our Guides, Articles, and How-To's

WordPress Database Guide

Category: WordPress
Tags: # # # #

What is a WordPress Database

The WordPress database is where information is stored regarding pages, posts, comments, themes, plugins, users – all kinds of great stuff!

Within the database there are 12+ tables which store specific, related information.

What Database Server Storage Engines are Supported by WordPress?

Currently MySQL and MariaDB. Perhaps someday we’ll see PostgresSQL.

What are the Default WordPress Database Tables?

  wp_comments  comments
  wp_commentmeta  metadata about comments
  wp_links  deprecated but can be enabled via links manager plugin
  wp_options  administration -> settings
  wp_posts  posts, pages and navigation menu items
  wp_postmeta  metadata about posts
  wp_term_relationships post association with categories and tags from wp_terms table
  wp_term_taxonomy  category, link or tag (taxonomy) for wp_terms entries
  wp_termmeta  metadata about terms
  wp_terms  categories, links and tags for posts
  wp_usermeta  metadata about users
  wp_users  users

Tables are specific to a particular set of information and relate to other tables so that additional information about it can be associated.

For example: Posts are stored in separate tables from comments. The two have a relationship so that the correct comment gets displayed with the correct post.

Here’s a diagram showing table contents and relationships:

WordPress Database Diagram

How Do WordPress Files Know How to Connect to a Database?

When you first install WordPress a file call wp-config-sample.php is placed on the server which you then need to copy as wp-config.php and edit to fit your hosting scenario.

Note: Many installers and hosting company scripts will create the correct file using data you provide during the installation process, so don’t sweat this for now.

When editing wp-config.php, avoid using Word and other word processors – use a text editor instead. Otherwise, odd characters can get inserted that will result in errors.

  wp-config.php Contents

The wp-config-sample.php file contains information about connecting to the database, key options and parameters such as security and optimization details. Here’s a breakdown of the wp-config.php file contents.

Note: When you see lines in the wp-config.php file starting with and ending with or starting with the text inbetween those are all comments. In other words, they don’t actually represent any instructions for the server to execute.


  // ** MySQL settings - You can get this info from your web host ** //
  /** The name of the database for WordPress */
  define( 'DB_NAME', 'database_name_here' );
  /** MySQL database username */
  define( 'DB_USER', 'username_here' );
  /** MySQL database password */
  define( 'DB_PASSWORD', 'password_here' );
  /** MySQL hostname */
  define( 'DB_HOST', 'localhost' );

You may also find:

  /** Database Charset to use in creating database tables. */
  define('DB_CHARSET', 'utf8');
  /** The Database Collate type. Don't change this if in doubt. */
  define('DB_COLLATE', '');


  define('SECURE_AUTH_KEY', 'cEh[n@U]RXB8D=F2.8f+L<GuLtE38J&T)(]Y0B~zs+KNmSN-2Pyanv,_0_z-V7[`');
  define('LOGGED_IN_KEY', 'n9]SF]^w_KI&<DiY+m@n:5#g:%V9XOE:9GJ!oj27-R$W7J}yN*4gUE+<+3wF%IAw');
  define('LOGGED_IN_SALT', 'dVM%Z}OHs7ZQv8]M&!)W*j`6[Qpw):u$0)BLfo5$U-+RV+_J_iJueUXg*wgQMj+D');

You should immediately change these for improved security.

How to Generate wp-config.php Security Keys?

Pop over to the secret key API and it’ll generate a new set for you. Hit refresh a few times and copy/paste the result over the top of your current keys in wp-config.php.

WordPress Keys


  $table_prefix = 'wp_';

This is the default. It’s recommended that something other than wp_ be used for security sake. Use letters, numbers and underscore only.


  define ('WPLANG', '');
  define('LANGDIR', '');

English is the default language. If you’d like to set language to something else, just the 2 letter language code – like: de inside the single quotes.


  define ('WPLANG', 'de');

You’ll also need to install the into the wp-content/languages folder (primary path) or wp- includes/languages (secondary path). Make sure that your 2 letter code matches the .mo file you install.

If you’d like to put the language file(s) in a different location, you can set that via LANGDIR.


  define('LANGDIR', 'wp-includes/lang');

See Frequently Asked Question Regarding the WordPress Database.