How To Change WP Table Prefix After Installation


security is the most preferred aspect for every blogger, therefore you should not forget to change wp table prefix after installation of wordpress in your blog.

as we all know that everyone don’t have enough courage to mess with the technicalities of database, but this article is allows you to change the wordpress database prefix without having to learn SQL language at all.

I recommend that make a backup of your database and wp-config.php file because both are going to be effected with our actions.

Why should you change wp prefix

well, this is the actual question that should come to your mind before doing anything because I felt the same when I heard it for the first time.

you should change wp prefix in wordpress for the improvement of the security level for your blog.

it prevents your blog from sql enjections and hackers won’t be able to run their random sql codes in the database of your blog.

it is highly recommended that you change wordpress db prefix if you are really concerned about the securety and don’t want to become a target of black hat hackers.

How to change wp prefix?

in order to change wp prefix for your wordpress blog, I have only two ifficient methods which won’t hurt your database at all.

the first method allows you to change your wp prefix with a sql query, and second one allow you to do this with a simple wordpress change table prefix plugin.

if you have confidence on your action, I recommend that you use sql query, otherwise wordpress change table prefix plugin is not a bad choice as well.

WordPress change table prefix sql query

in order to change prefix with sql query, do the following:

  1. Login to your FTP account
  2. navigate to Wp-admin/config.php and open it
  3. replace the prefix name from the following line
    $table_prefix = ‘wp_test_’;
    Note: Wp_test_” is a new name of your prefix and you can replace it with any other you prefer
  4. save your wp-config.php and close ftp client
  5. login to your CPanel and navigate to the phpmyadmin under the databases tab
  6. click on your database under the databases section
  7. now click on SQL
  8. here you will see an edit box to run a sql query.
  9. copy and paste the same query to that database
    RENAME table `wp_commentmeta` TO `Wp_Test_commentmeta`;
    RENAME table `wp_comments` TO `Wp_Test_comments`;
    RENAME table `wp_links` TO `Wp_Test_links`;
    RENAME table `wp_options` TO `Wp_Test_options`;
    RENAME table `wp_postmeta` TO `Wp_Test_postmeta`;
    RENAME table `wp_posts` TO `Wp_Test_posts`;
    RENAME table `wp_terms` TO `Wp_Test_terms`;
    RENAME table `wp_termmeta` TO `Wp_Test_termmeta`;
    RENAME table `wp_term_relationships` TO `Wp_Test_term_relationships`;
    RENAME table `wp_term_taxonomy` TO `Wp_Test_term_taxonomy`;
    RENAME table `wp_usermeta` TO `Wp_Test_usermeta`;
    RENAME table `wp_users` TO `Wp_Test_users`;
    You may have to add lines for other plugins that may add their own tables in the WordPress database. The idea is that you change all tables prefix to the one that you want.
  10. WP Options
    We need to search the options table for any other fields that is using wp_ as a prefix, so we can replace them. To ease up the process, use this query:
    SELECT * FROM `WP_Test_options` WHERE `option_name` LIKE ‘%wp_%’
    This will return a lot of results, and you need to go one by one to change these lines.
  11. User meta table
    we need to search the usermeta for all fields that is using wp_ as a prefix, so we can replace it. Use this SQL query for that:
    SELECT * FROM `WP_Test_usermeta` WHERE `meta_key` LIKE ‘%wp_%’
    Number of entries may vary on how many plugins you are using and such. Just change everything that has wp_ to the new prefix.
  12. Exit the CPanel and enjoy.

that’s all, you have successfully changed the wp prefix.

change wp prefix plugin

this method is recommended for newbi bloggers who don’t feel comfortable with codes and prefer an easy button instead.

in order to change your wordpress prefix, you just need to install and activate Change Table Prefix with your wordpress site.

upon activation, a new link called “Change table prefix” will be added under the settings tab of your worrdpress dashboard.

click the link and there you will see some options.

the first checkbox allows you to put your website on maintenance mode so your regular visitors won’t see your site during update period of time, it’s highly recommended that you put your website on maintenance mode during this procedure.

the second check box allows you to sett a custom prefix for your blog or website.

if the second checkbox will remain unchecked, the random prefix will be generated and you can add your custom prefix by checking this checkbox.

after writing the valid prefix in edit box. click change table prefix.

after you click the button below, the plugin will change all of your tables prefix and displays all the results.

have you any other method to change wp table prefix after installation of wordpress? let me know in comments.


Please enter your comment!
Please enter your name here