KNOWNHOST WIKI

User Tools

Site Tools


resources:wordpress-database-guide

WordPress Database Guide

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:

1) 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.

DATABASE CONNECTION AND STRING HANDLING

  // ** 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', '');

SECURITY KEYS

  define('AUTH_KEY','F~)M6NUROA{!D+z&Lw/1S4CSN_Ba/Kv]L<rU*%X:_=[URiuwh^!fC3r6TN,4QHSv');
  
  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('NONCE_KEY','Oi~%Gno,_1W1iZs:Mjthu7y*cs4:A0UEavP8K&D|hlugV:Zp>xnggIR2a6ZG&(5$');
  
  define('AUTH_SALT','l|o:wBFNU|+a0Q]t!P$1qyQcd3H4.~|x)F#I{Bc2@]4&mJounFDXBE#]GeA;&8u');
  
  define('SECURE_AUTH_SALT','vhj%dQPbaPUBluq}(2~H8/$#/AF^F4pT/7q_3zQ;|U7#M^`{(23).RKXLj2O(4qB');
  
  define('LOGGED_IN_SALT', 'dVM%Z}OHs7ZQv8]M&!)W*j`6[Qpw):u$0)BLfo5$U-+RV+_J_iJueUXg*wgQMj+D');
    
  define('NONCE_SALT','q^&f<lj.e49Y}I1Yl]/{u8j+jt<A7YN|Zr[NicVyEF@$>uM$Fcl?]k{r5e9V9p+');

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.

2) WordPress Keys

DATABASE TABLE PREFIX

  $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.

LOCALIZED LANGUAGE

  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.

Example:

  define ('WPLANG', 'de');

You'll also need to install the de.mo 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.

Example:

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

See Frequently Asked Question Regarding the WordPress Database. 3)(LINK TO NEW FAQ WP DATABASE PAGE)

resources/wordpress-database-guide.txt · Last modified: 2020/06/15 11:01 by Karson N.