Change wordpress table prefix updated 2022 How to change wordpress table prefix NOTE: replace NEWPREFIX_ and OLDPREFIX_ with yours NEWPREFIX_ OLDPREFIX_ Step 1
How to change wordpress table prefix
NOTE: replace
NEWPREFIX_
andOLDPREFIX_
with yours
Step 1
Change variable value of wp-config.php
- Login to your control panel or via FTP.
- Open File Manager under Files & Security.
- Locate the file wp-config.php and check the box to select it.
- Edit the wp-config.php.
- Locate the following entry:
$table_prefix = 'OLDPREFIX_';
- Replace with new entry:
$table_prefix = 'NEWPREFIX_';
Step 2
Update SQL database to change wordpress table prefix
- Open your database in PhpMyAdmin.
- Click on the database name in the menu to the left to unfold all tables.
- Select all tables that start with wp_; you should have 12 in total.
- Click With selected to open the drop-down menu and select Replace table prefix.
- Type in wp_ in the From-field, and the new name in the To-field, in this example, david_.
- Click Continue to make the change.
Rename table
RENAME table `OLDPREFIX_commentmeta` TO `NEWPREFIX_commentmeta`;
RENAME table `OLDPREFIX_comments` TO `NEWPREFIX_comments`;
RENAME table `OLDPREFIX_links` TO `NEWPREFIX_links`;
RENAME table `OLDPREFIX_options` TO `NEWPREFIX_options`;
RENAME table `OLDPREFIX_postmeta` TO `NEWPREFIX_postmeta`;
RENAME table `OLDPREFIX_posts` TO `NEWPREFIX_posts`;
RENAME table `OLDPREFIX_terms` TO `NEWPREFIX_terms`;
RENAME table `OLDPREFIX_termmeta` TO `NEWPREFIX_termmeta`;
RENAME table `OLDPREFIX_term_relationships` TO `NEWPREFIX_term_relationships`;
RENAME table `OLDPREFIX_term_taxonomy` TO `NEWPREFIX_term_taxonomy`;
RENAME table `OLDPREFIX_usermeta` TO `NEWPREFIX_usermeta`;
RENAME table `OLDPREFIX_users` TO `NEWPREFIX_users`;
Update usermeta
update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_capabilities' where meta_key = 'OLDPREFIX_capabilities';
update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_user_level' where meta_key = 'OLDPREFIX_user_level';
update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_autosave_draft_ids' where meta_key = 'OLDPREFIX_autosave_draft_ids';
update NEWPREFIX_options set option_name = 'NEWPREFIX_user_roles' where option_name = 'OLDPREFIX_user_roles';