How to Change Your WordPress Table Prefix October 23, 2011Posted by Tournas Dimitrios in Wordpress - 3.
Often it’s recommended that as a WordPress site owner , you change your WordPress database table prefix to something other than wp_ . It’s not a bad idea – in certain situations, doing so might prevent a hacker from gaining more access to your site , or limit his destructive capability, and it’s a very easy thing to change . By defauld WordPress append the prefix ” wp_ ” to each database table . If you haved installed WordPress through the installation process , you where asked to define the table prefix to anything you’d like and WordPress’s configuration file was updated with this new prefix ( $table_prefix directive ) .
If you’ve already installed WordPress , you can still change your table prefix , but it’s a little more complicated . You’re going to need to have access to your database through PHPMyAdmin or your host’s control panel .
- Download via FTP your WordPress’s configuration file ” config.php”
- Open the file with your favorite editor and edit the $table_prefix directive to whatever you’d like.
- Store the changes you have made into the file and upload it back to your server via FTP ( replacing the old wp-config.php file ) .
- Connect via a web-browser to your database ( usually hosts provide phpMyadmin)
- Run through each table starting with wp , and rename it as follows :
1) Click on the table name in the left sidebar
2) Click on the “Operations” tab
3) Change “wp_” to the prefix you had defined a few steps above
At this point , your site should be working properly again , but You get a permissions error when you try to log in . Choose the usermeta table (with the new prefix you had defined previously ) , and look for a row with a user_id of 1 (root user), and a “meta_key” value of “wp_capabilities”. Once you’ve found this , Click the pencil toward the left (edit) and replace the wp_ in the meta_key row to your custom prefix . You need to make this same change to 2 more records – wp_user_level (located in wp_usermeta –table , and wp_user_roles , which is in the options table .
The plugin WP Security Scan will do all the dirty work for you in most cases . Just log-in your WordPress admin panel , install and activate the plugin . Now the left-sidebar has a Security -> Database link . Trough the “Database” link the prefix can be customized .