💾 WordPress technical: Database

All the dynamic data you see on WordPress sites, is stored in an SQL database.
For example:

  • WordPress users and userdata
  • Posts
  • Comments
  • Pages
  • Menus
  • List of plugins and themes with version numbers and states (active/deactive)
  • Theme settings
  • All the settings of all the plugins
  • Different WordPress options
  • Metadata of media files (titles, URLs, ids)
  • Custom post types
  • etc…

For everything that is shown in your wp-admin, or on your live website, the data is queried from this database using PHP and SQL syntax.

Basic WordPress database

WordPress database tables have its own prefix, which you can set during the installation, or change later from wp-config.php. The prefix is set, so you won’t overwrite your other tables in the same database, should you want to run some other projects alongside.

The default prefix is “wp_”.

On the picture above, you can see:

  • “wp_bwg_” tables – these tables are added by some gallery plugin and contain all the necessary data this plugin needs for running.
  • “wp_patchstack_” tables – these tables are added by Patchstack and they contain data about WordPress user activity logs, and firewall protection logs
    Patchstack data is synced to Patchstack App multiple times per day. During syncing process, our plugin truncates these WordPress tables regularly, to not bloat the users database with thousands of rows and making their sites slow.
  • “wp_” tables – these are the ones that come by default with WordPress and are needed for WordPress to function.

The most interesting tables are wp_options, wp_posts and wp_users.

wp_options table

Mostly, this table has all the data about different plugin and theme settings. First 150+ rows are WordPress built-in functions, like siteurl, home url, website title (blogname), admin email, start day of week, etc.

This is also the table where Patchstack stores all the virtual patches, firewall rules, and all Patchstack plugin related settings and API keys to make the connection between the Patchstack plugin and Patchstack App.

Note that in this table, you can see patchstack_secretkey, which is hashed version of the API. It is hashed into this format, using WordPress salts.

Feel free to browse this table and see all the settings there.

Virtual patches in wp_options table

In this case, the site has 3 virtual patches for the plugin Contact form 7. Virtual patches are stored in the “patchstack_firewall_rules_v3” table.

wp_users table

This table has all the data about WordPress users. You can change the user emails from there (if you need to change your main admin user email for example, because you can’t do that within WordPress).
Password is hashed.

wp_posts table

This table has all the data about all the page and post content you have on your WordPress website.
Change anything in this table, and you see the changes on your website.

Scroll to Top