Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To change a WordPress database prefix on an existing site, you must do three things together: rename every table that uses the old prefix, update prefix-bearing keys in the usermeta table, and change $table_prefix in wp-config.php. Changing the PHP setting alone makes WordPress look for tables that do not exist and can trigger the installation screen. Take and verify a restorable database backup before any SQL edit.

What the table prefix does

The $table_prefix value in wp-config.php is placed at the beginning of WordPress database table names. A standard installation uses wp_, producing names such as wp_posts, wp_options and wp_users. WordPress does not require that default; a site can use a unique value such as site7_.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The prefix is part of the database schema, not merely a display preference. Existing table names and certain metadata keys must agree with the value in the configuration file. If they do not, WordPress cannot find its settings, users or content and may behave as though it has never been installed.

Before you start: protect the site and inventory its tables

1. Confirm the current prefix

Open wp-config.php and locate a line similar to:

$table_prefix = 'wp_';

Then inspect the database itself. In a MySQL client, you can list tables beginning with the current prefix (the backslash escapes the underscore wildcard):

SHOW TABLES LIKE 'wp_%';

Record every result. Include tables created by plugins or custom code if they use the old prefix; renaming only WordPress core tables leaves the installation inconsistent.

2. Export a complete, restorable backup

Export the entire WordPress database, not just the tables you expect to rename. Keep a copy outside the hosting account. A backup is useful only if it can be restored, so verify that the export opens correctly and, where possible, perform a test import into a separate database. Database renames and metadata updates are permanent operations unless you restore that copy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Schedule a maintenance window

Prevent logins and content changes while the rename runs. Put the site in maintenance mode or temporarily restrict access, and pause jobs that write to WordPress. Do not let visitors create comments or orders between the table rename and the configuration change.

Choose a valid new prefix

Use only letters, numbers and underscores. A trailing underscore is recommended because it keeps table names readable, for example site7_ rather than site7. The value is case-sensitive in some operating-system and database configurations, so use the exact same spelling everywhere.

  • Good examples: site7_, client2026_, blog_eu_.
  • Avoid spaces, hyphens, punctuation and accented characters.
  • Do not choose a prefix that is already used by another installation in the same database.

Rename the tables

Option A: use SQL

A SQL client is repeatable and easy to place in a change record, but it requires you to identify the correct database and to maintain an independently verified backup. Replace the example names below with your actual old and new prefixes.

RENAME TABLE
  wp_commentmeta       TO site7_commentmeta,
  wp_comments          TO site7_comments,
  wp_links             TO site7_links,
  wp_options           TO site7_options,
  wp_postmeta          TO site7_postmeta,
  wp_posts             TO site7_posts,
  wp_termmeta          TO site7_termmeta,
  wp_terms             TO site7_terms,
  wp_term_relationships TO site7_term_relationships,
  wp_term_taxonomy     TO site7_term_taxonomy,
  wp_usermeta          TO site7_usermeta,
  wp_users             TO site7_users;

Older or customized installations may contain additional core-era tables, and plugins commonly add their own. Query the inventory you recorded and create a rename entry for every table whose name starts with the old prefix. Do not rename unrelated tables that happen to share a similar word but belong to another application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If your database account does not have permission to rename tables, stop rather than substituting a partial operation. Ask the host for the required privilege or use the host’s database administration interface.

Option B: use phpMyAdmin or Adminer

  1. Select the database used by WordPress, checking its name against the DB_NAME value in wp-config.php.
  2. Filter or scan the table list and mark every table with the old prefix, including plugin-created tables.
  3. Use the table’s Rename table action and replace only the prefix, preserving the remainder of the name.
  4. Review the resulting list for omissions and accidental changes before leaving the page.

A graphical interface makes visual inventory and row inspection easier, but it does not make an incomplete selection safe. The important control is a complete list and a tested backup.

Update prefix-bearing user metadata

WordPress stores roles and capabilities in the usermeta table. The metadata keys normally begin with the table prefix, for example wp_capabilities and wp_user_level. After renaming wp_usermeta to site7_usermeta, change those keys to use the new prefix.

UPDATE site7_usermeta
SET meta_key = REPLACE(meta_key, 'wp_', 'site7_')
WHERE meta_key LIKE 'wp_%';

Adapt both prefixes to your site. The WHERE clause limits the operation to keys beginning with the old value. Before committing, inspect the affected rows:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
SELECT umeta_id, user_id, meta_key
FROM site7_usermeta
WHERE meta_key LIKE 'site7_%'
ORDER BY umeta_id;

Check that administrator and other role records are present and that no unrelated key was rewritten. If your installation uses custom code that deliberately stores the old prefix in a metadata key, review those rows individually instead of applying a blanket replacement.

Change wp-config.php

After the database tables have been renamed, edit the configuration line to the exact new value:

$table_prefix = 'site7_';

Keep the quotes and semicolon. The file must be the one used by the live installation, normally the wp-config.php in the WordPress document root. Do not leave the site running for an extended period with the database and configuration pointing at different prefixes.

Verify the result before reopening the site

  1. Load the front end in a private browser window and confirm that posts, pages, media references and menus appear normally.
  2. Open /wp-admin/ and sign in with an existing administrator account.
  3. Check that the account still has the expected role and that another representative role, such as an editor, retains its permissions.
  4. Open the settings screens that read and write options, then save a harmless setting to confirm the new options table is writable.
  5. Exercise important plugins and integrations, especially those that create custom tables or scheduled tasks.
  6. Review the PHP and web-server error logs for missing-table errors, database permission failures or fatal plugin errors.

If WordPress displays the setup wizard or an empty site, stop testing and do not complete a new installation. That symptom usually means the prefix in wp-config.php does not exactly match the renamed tables, or that the wrong database was selected. Correct the names from your inventory or restore the backup, then repeat the procedure during maintenance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Manual SQL, database GUI or migration plugin?

Method Strengths Risks and requirements
SQL client Repeatable, scriptable and precise when the table inventory is complete. Requires MySQL knowledge, correct database selection and a verified backup. A typo can affect the wrong table.
phpMyAdmin or Adminer Visual table list, rename controls and convenient row inspection. Depends on host access and careful selection. Selecting only the obvious core tables can leave plugin tables behind.
Migration plugin May automate search-and-replace workflows for operators who do not use SQL. Compatibility, maintenance status and behavior for your WordPress and plugin combination must be checked separately. Do not assume a plugin handles every custom table or metadata key.

None of these methods is automatically safer. The safer choice is the one you can execute with a complete inventory, an off-site backup and a rollback plan.

Does changing the prefix improve security?

WordPress hardening guidance notes that many published WordPress-specific SQL-injection attacks assume the default wp_ prefix; using a different value can block at least some attacks that rely on that assumption. This is a limited defense-in-depth measure, not a vulnerability fix.

  • Keep WordPress, themes and plugins updated.
  • Use a database account with only the privileges the site needs.
  • Protect administrator accounts with strong, unique credentials and appropriate additional authentication.
  • Maintain tested backups and monitor for unexpected database or file changes.
  • Use an application firewall or equivalent controls where they fit your environment.

Careless security changes can introduce outages or new weaknesses. Do not change a production prefix without the backup, maintenance window and verification steps described above.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

New installations and shared databases

For a new WordPress installation, choose the unique prefix during setup rather than migrating later. In wp-config.php, set the value before the installer creates tables. When several WordPress installations share one database, each installation must have its own prefix so that tables and user metadata do not overlap.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An existing site requires migration because its tables and prefix-bearing keys already exist. A new site avoids that rename work, but you must still record the chosen prefix and preserve it in backups and deployment documentation.

Troubleshooting common failures

Symptom Likely cause Action
Installation screen appears $table_prefix points to names that were not created, or the wrong database was selected. Compare the configuration value with SHOW TABLES results. Restore the backup if the mismatch is not obvious.
Login works but the user has no administrator rights Role and capability keys in usermeta still use the old prefix, or were edited incorrectly. Inspect the affected user’s rows, verify the new meta_key values and restore from backup if rows were overwritten.
Some plugin features fail A plugin table was omitted or the plugin expects a custom prefix-bearing key. Compare the pre-change inventory with the renamed tables, then inspect the plugin’s documented schema or restore and retry.
SQL reports a permission or table-name error The account lacks rename privileges, or a table name was mistyped. Stop, correct the statement or obtain the required database privilege; do not continue with a partial rename.
Content appears missing The site is connected to a different database or the posts table was not renamed to the configured prefix. Check DB_NAME, host and credentials in wp-config.php, then verify the posts table name.

Final change checklist

  • Complete database export stored off-site and restore tested.
  • Old prefix recorded from both configuration and table inventory.
  • New prefix uses only letters, numbers and underscores, with consistent spelling.
  • Every core and plugin table renamed.
  • Prefix-bearing keys in the renamed usermeta table updated and inspected.
  • $table_prefix changed to the same value.
  • Front end, dashboard, roles, settings and critical plugins verified.
  • Rollback copy retained until the site has operated normally through its next maintenance cycle.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.