The other day I had to change the WordPress table prefix for my Road Less Travelled Blog.
It took a while but I eventually found instructions at the Pi in the Sky Blog.
They’ve been re written here in a more summarised form:
- Change the table prefix in wp-config.php and upload it to your web server. Let’s say we still have the default prefix wp_.
$table_prefix = 'wp_';
$table_prefix = 'wp_new_';
Note that wp_new_ is just an example. You can call the prefix anything you want as long as you use only letters (a-z), numbers (0-9) and underscores (_), eg: jims_wp22_blog_.
- You need to manually change the name of all the wordpress tables in your MySQL database from the original prefix eg: wp_ to the new prefix using manual SQL queries or PHPmyAdmin which I find much easier to use, eg:
RENAME wp_posts TO wp_new_posts;
- The last step is to manually change some fields in your newly renamed WordPress tables which still have the old prefix at the beginning of their name:
For table wp_new_options
wp_user_roles becomes wp_new_user_roles
For table wp_new_usermeta
wp_capabilities becomes wp_new_capabilities
wp_user_level becomes wp_new_user_level
wp_autosave_draft_ids becomes wp_new_autosave_draft_ids
Note: xx_autosave_draft_ids won’t be there unless you have saved drafts of posts while editing them.
Following these instructions I changed the WordPress MySQL Database Table Prefix on all my blogs to something very hard to guess in less than 3 minutes, which improves their protection against hackers.
PS While you’re here, you probably know that WordPress automatically reformats single quotes when you’re trying to display some code which means it won’t display properly and people can’t cut and paste it.
So next time you need to display a single quote in a WordPress post do it using this HTML character code:
' and it will display as you intended