Database navigation guide
Change the WordPress table prefix safely.
Renaming wp_ to something else touches more than the table names — serialized data and per-user meta keys embed the prefix too, and a naive find-and-replace corrupts both.
A non-default prefix is not meaningful security on its own — reconsider whether this is worth doing before you start.
A raw SQL REPLACE() breaks any serialized value whose byte-length no longer matches after the edit.
Tables, wp-config.php, and specific wp_usermeta keys all embed the prefix — miss one and the site breaks in a different way.
Why people actually do this
Two reasons hold up. Consolidating several WordPress installs into one shared database, where table names would otherwise collide, is a real and common one. A hosting or compliance requirement that mandates a specific naming scheme is another. "Security" on its own is weaker than it sounds — a distinctive prefix is not meaningful defense in depth by itself, since anyone with database access already has everything the prefix was supposedly hiding. WordPress's own hardening guidance treats it as a minor, optional step, not a primary control. Put the effort into file permissions, account hygiene, and staying current instead, and only rename the prefix when you have one of the two real reasons above.
What actually has to change
A plain RENAME TABLE handles the tables themselves and nothing else. Three more places embed the prefix and are easy to miss:
TablesEach oldprefix_* table renamed to newprefix_*WordPress can't find its own data at allwp-config.phpThe $table_prefix constant updated to matchWordPress keeps querying the old (now-renamed) table nameswp_usermeta keysExact-match keys like wp_capabilities and wp_user_level renamed to the new prefixEvery user silently loses their role and capabilitiesSerialized valuesAny serialized array or object containing the old prefix as a substringCorrupted on a byte-length mismatch from a naive replace, not just unchangedA safe order of operations
- 01Back up, and enable maintenance mode.
Verify the backup actually restores before you rely on it — this is exactly the kind of change where you'll want that proof.
- 02Rename each table.
RENAME TABLE oldprefix_posts TO newprefix_posts;for every table — a plain rename is safe here, since a table name isn't serialized data. - 03Update
wp-config.php.Set
$table_prefixto the new value. WordPress reads this on every request, so an unmatched prefix here undoes step 02 immediately. - 04Fix the exact-match usermeta keys.
A plain
UPDATEonmeta_keyvalues likeoldprefix_capabilitiesandoldprefix_user_levelis safe — these are fixed strings, not serialized blobs. - 05Run a serialization-aware search-replace for anything left over.
WP-CLI's
wp search-replaceis built specifically to rewrite strings inside serialized PHP data without corrupting it — use it to catch any remaining reference to the old prefix, not a raw SQLREPLACE(). - 06Test exhaustively before going live.
Confirm login, every user's role and capabilities, and plugin functionality on a staging copy first. On multisite, repeat this for every subsite's numbered tables, not only the shared ones.
Quick answers
Does changing the table prefix meaningfully improve security?
Only marginally. It's not WordPress's own primary hardening recommendation, and anyone with database access already has what the prefix would have hidden. Treat it as housekeeping, not a security control worth disrupting a live site over.
Can WP-CLI rename the prefix for me in one command?
No single built-in command does the whole job safely. wp search-replace handles the serialized-data cleanup step well, but renaming the tables and editing wp-config.php are separate, manual steps.
What happens if I miss the wp_capabilities meta key?
Every user account loses its role and capabilities from WordPress's point of view — which can look identical to a broken login even though the password itself is completely fine.
Is this safe to do on a live multisite network?
Meaningfully riskier — every subsite has its own numbered table set that needs the same treatment, and a missed table on any one subsite breaks just that site. Test the full procedure on a staging copy of the whole network first.
Primary reference: WP-CLI: wp search-replace.