Skip to content

Instantly share code, notes, and snippets.

@seankmchenry
Created July 13, 2016 05:22
Show Gist options
  • Save seankmchenry/3847e1af2795e95e502ff8ae614ffbb2 to your computer and use it in GitHub Desktop.
Save seankmchenry/3847e1af2795e95e502ff8ae614ffbb2 to your computer and use it in GitHub Desktop.
4 Steps for changing your WordPress database table prefix
1. Change table prefix in wp-config.php
2. Change table names. Script below:
RENAME table `wp_commentmeta` TO `new_commentmeta`;
RENAME table `wp_comments` TO `new_comments`;
RENAME table `wp_links` TO `new_links`;
RENAME table `wp_options` TO `new_options`;
RENAME table `wp_postmeta` TO `new_postmeta`;
RENAME table `wp_posts` TO `new_posts`;
RENAME table `wp_terms` TO `new_terms`;
RENAME table `wp_termmeta` TO `new_termmeta`;
RENAME table `wp_term_relationships` TO `new_term_relationships`;
RENAME table `wp_term_taxonomy` TO `new_term_taxonomy`;
RENAME table `wp_usermeta` TO `new_usermeta`;
RENAME table `wp_users` TO `new_users`;
3. Search options table for fields with old prefix:
SELECT * FROM `new_options` WHERE `option_name` LIKE '%wp_%'
4. Same search, but in the user meta table:
SELECT * FROM `new_usermeta` WHERE `meta_key` LIKE '%wp_%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment