Blog WordPress

change wordpress table prefix

As part of hardening your WordPress installation, it is recommended that we change the prefix of our WP tables. In that way, the 'bad guys' and script kiddies will have to guess the name of your tables.

Step 1

Suppose that you want mod as your new table prefix, run the following in your phpMyAdmin.

RENAME TABLE wp_commentmeta TO mod_commentmeta
,wp_comments TO mod_comments
,wp_links TO mod_links
,wp_options TO mod_options
,wp_postmeta TO mod_postmeta
,wp_posts TO mod_posts
,wp_terms TO mod_terms
,wp_term_relationships TO mod_term_relationships
,wp_term_taxonomy TO mod_term_taxonomy
,wp_usermeta TO mod_usermeta
,wp_users TO mod_users;

Step 2

UPDATE `mod_options`
SET `option_name` = 'mod_user_roles'
WHERE `option_name` ='wp_user_roles'
AND `blog_id` =0;

Step 3

UPDATE `mod_usermeta`
SET `meta_key` = REPLACE( `meta_key` , 'wp_', 'mod_' )
WHERE option_name LIKE 'wp_%';

The preceding two steps are needed because in the later versions of WordPress, some tables are converted to records. Skipping these two steps will lead to permission error. To be specific, the error is as below.
You do not have sufficient permissions to access this page.

Hmn... well, that's just it.

Usual Disclaimer

Renaming your table doesn't mean that you'll be safe from the bad guys (otherwise known as 'hackers'). It's just one of the holes to plug and will only help in hardening your installation. However, be aware that there could be other things that can break or compromised. So be vigilant and always install the latest version of WordPress.