---
title: "What is the WordPress database table prefix? | WP Ministry"
url: https://wpministry.co/glossary/database-table-prefix/
description: "The table prefix starts the name of every WordPress database table, wp_ by default. It is set in wp-config.php and also written inside the database."
lang: en-US
---

Skip to content

# Database table prefix

The table prefix is the few characters at the start of every WordPress database table's name, wp_ unless it was changed at setup. It is set in wp-config.php and it is also written inside the database, which is why changing it by hand locks administrators out.

By

WP Ministry

Published

October 8, 2026

## In short

- The prefix is set by the $table_prefix line in wp-config.php and starts every table's name. The default is wp_.
- Any SQL you copy from a guide is written for wp_. Change the table names, and any key built from the prefix, to match yours.
- The prefix is also inside the names of the rows that hold roles. Change the prefix without renaming them and no account can open the dashboard.

The table prefix is the text WordPress puts at the start of the name of every table it keeps in its database. The default is `wp_`, so posts are in `wp_posts`, settings in `wp_options` and users in `wp_users`. One line in wp-config.php (https://wpministry.co/glossary/wp-config-php/) sets it:

wp-config.php

```
$table_prefix = 'wp_';
```

It exists so that more than one WordPress installation can share one database: each has a prefix of its own, and their tables never meet. WordPress's documentation says to keep security in mind if you do that. The prefix may hold only numbers, letters and underscores.

## Where you meet it

- **At setup.** WordPress asks for it in a field named "Table Prefix", with the note "If you want to run multiple WordPress installations in a single database, change this."
- **In `wp-config.php`,** on the line above. The wp-config.php generator (https://wpministry.co/tools/wp-config-generator/) asks for it too.
- **In every table's name,** in whatever tool your host gives you for the database.
- **In SQL copied from a guide.** A query written for `wp_options` finds nothing, or fails, on a site whose table is `abc_options`.
- **On a multisite network.** The first site uses the prefix alone. Each further site adds its number, as in `wp_2_posts`.

## What goes wrong

The prefix is in more places than the table names. WordPress also builds the names of a few rows from it. With `wp_` they are:

| Table | Row | Holds |
| --- | --- | --- |
| options | `wp_user_roles` | The site's roles and what each may do |
| user meta | `wp_capabilities` | One user's role |
| user meta | `wp_user_level` | A number WordPress works out from that role |

That is what breaks when the prefix is changed by hand.

- **Only the line in `wp-config.php` is changed.** WordPress looks for tables that do not exist and concludes the site is new. Every address leads to the installation screen. Nothing is lost: put the old prefix back and the site returns. WordPress's sample file warns of exactly this.
- **The tables and the line are changed, the rows are not.** The site loads and everyone can log in, but WordPress finds no roles under the new name. Every dashboard screen answers "Sorry, you are not allowed to access this page." How to fix it (https://wpministry.co/errors/sorry-you-are-not-allowed-to-access-this-page/) has the three statements that rename the rows.
- **A query uses the wrong prefix.** This is the usual reason a copied query returns nothing. The key is the part people miss: listing administrators means reading `abc_capabilities`, not `wp_capabilities`. See what to do about an unknown admin user (https://wpministry.co/blog/unknown-admin-user-wordpress/) and how to clean up a WordPress database (https://wpministry.co/blog/optimize-wordpress-database-speed/), which both say where the prefix goes.

Not every name that starts with `wp_` comes from the prefix. The option `wp_page_for_privacy_policy` has that name on every site, whatever the prefix. Rename only the rows above.

## How to look at yours

Go to Tools, then Site Health, open the Info tab and expand Database. The row is "Table prefix". With WP-CLI:

bash

```
wp config get table_prefix
```

## Common questions

Should I change the table prefix for security?

WordPress's hardening guide says many published SQL injection attacks assume the prefix is `wp_`, and that another prefix can block at least some of them. It lists the change under security through obscurity, which it calls generally an unsound primary strategy. Choosing another prefix at setup costs nothing. On a site that is already running, the change is the risky operation described above.

How do I change the prefix on a site that is already running?

Export the database first. Then rename every table, change `$table_prefix` to match, and rename the three rows in the table above to the new prefix. All three steps have to be done before the dashboard works again. Try it on a staging copy first.

## Not sure what is wrong?

Tell us what you see. We reply with the cause and a fixed quote, and the diagnosis is free.

Get a free diagnosis: https://wpministry.co/free-diagnosis/

May we measure how this site is used?

A yes notes the pages of this visit and loads Google Analytics. A no keeps and loads nothing. See the cookies page (https://wpministry.co/legal/cookies/).

If you say yes, we note the pages you look at during this visit and load Google Analytics. If you say no, nothing is kept and nothing is loaded. The site works the same either way. The cookies page (https://wpministry.co/legal/cookies/) has the details.

## Structured data

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Organization",
      "@id": "https://wpministry.co/#organization",
      "name": "WP Ministry",
      "url": "https://wpministry.co/",
      "logo": "https://wpministry.co/brand/logo.png",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "1309 Coffeen Ave STE 1200",
        "addressLocality": "Sheridan",
        "addressRegion": "WY",
        "postalCode": "82801",
        "addressCountry": "US"
      },
      "sameAs": [
        "https://www.linkedin.com/company/wp-ministry/",
        "https://x.com/wpministryco",
        "https://www.instagram.com/wpministryco/",
        "https://www.facebook.com/wpministryco",
        "https://www.tiktok.com/@wpministryco",
        "https://www.pinterest.com/wpministryco/",
        "https://www.youtube.com/channel/UCOZRuAukk5QSTRPG6BaHl3Q"
      ]
    },
    {
      "@type": "WebSite",
      "@id": "https://wpministry.co/#website",
      "name": "WP Ministry",
      "url": "https://wpministry.co/",
      "inLanguage": "en-US",
      "publisher": {
        "@id": "https://wpministry.co/#organization"
      }
    },
    {
      "@type": "DefinedTerm",
      "@id": "https://wpministry.co/glossary/database-table-prefix/#term",
      "name": "Database table prefix",
      "description": "The table prefix starts the name of every WordPress database table, wp_ by default. It is set in wp-config.php and also written inside the database.",
      "url": "https://wpministry.co/glossary/database-table-prefix/",
      "inDefinedTermSet": "https://wpministry.co/glossary/"
    },
    {
      "@type": "BreadcrumbList",
      "itemListElement": [
        {
          "@type": "ListItem",
          "position": 1,
          "name": "Home",
          "item": "https://wpministry.co/"
        },
        {
          "@type": "ListItem",
          "position": 2,
          "name": "Glossary",
          "item": "https://wpministry.co/glossary/"
        },
        {
          "@type": "ListItem",
          "position": 3,
          "name": "Database table prefix"
        }
      ]
    }
  ]
}
```