How to Change WordPress Database Prefix – WordPress Security

If you are looking to make your WordPress blog secure, you need to consider several things. Changing WordPress database prefix is one of them. Most of the hackers run automated codes for SQL injection. If they successful, they would receive all information stored in your MySQL database. Most of the users upon installing new WordPress , forget to change their WordPress database table prefix.

Bydefault, it has been set as wp_……… But when you change it, it would be more difficult for hackers to get your blog’s information from WordPress MySQL Database. It would prevent your blog from WordPress Security Issues. You can change WordPress database prefix using two ways. First one is easiest method if you don’t want to play with coding and messing up with your database. Another one is using phpMyAdmin. You can choose anyone method described here that you think easiest for you.

What is the WordPress Database Table Prefix? 

The WordPress database table prefix is simply a string of letters and numbers that are used when assigning names to the tables of the WordPress database. Bydefault it’s WP_…… that is automatically set after fresh WordPress installation.

Before you proceed :

Before you start process of changing WordPress database table’s prefix, you should have to backup your WordPress database. So you can Restore WordPress Databases it in-case you have followed any wrong step during process.

Method 1 : Using phpMyAdmin to change database table prefix :

This is little difficult method but if you like to play with codes, this would be the simplest method. Backup WordPress database and wp-config.php file first before proceeding next steps.

1. First of all you have to configure wp-config.php file & change database prefix name you want to set. You would find WordPress directory in WordPress root folder.You can search for $table_prefix line from your wp-config.php file.

2. Change the names of the database tables: If you don’t know Where Is My WordPress Database , you can login to your wordpress phpMyAdmin and find SQL database from there. Here is the sample image of phpMyAdmin. It is difficult to rename all database tables separately however you can run SQL query to rename all database.

Run SQL To Rename database TablesSuppose your WordPress database prefix is WP_ , then run following query on SQL. You would have to Update User Meta fields & Update options table data. Here is quick procedure to update it.

3. Update User Meta fields : If you do not update it, you and other users would not able to log in to your wordpress blog. This is important part while updating and renaming WordPress database prefix.TO update user meta fields, you need to run following SQL query.

UPDATE `new_prefix_usermeta` SET `meta_key` = REPLACE( `meta_key`, 'wp_', 'my_new_prefix_' )

4. Update options table data :

Use below commands to update option table data.

UPDATE `new_prefix_options` SET `option_name` = 'new_prefix_user_roles' WHERE `option_name` = 'wp_user_roles'

You have done.

Well, if you don’t like to use the above method, you can use WordPress plugin to change WordPress database prefix. Changing database prefix would make your blog with BulletProof Security WordPress setup.

Method 2 : Use WordPress Plugins to Change WordPress Database prefix :

Change DB Prefix – This plugin is available free on WordPress plugin’s directory. This Plugin is basically for changing the database default prefix(wp_) to other one.Change WordPress database PrefixThis is the simplest plugin I have found. Just Enter your existing prefix and new prefix there and click on save. It would rename your database table prefix directly from your WordPress dashboard. You would not have to login to your phpMyAdmin and change it.

Change Table Prefix – This is also simplest plugin to increase your website’s security. After you change your database table prefix, it would helps you to prevent your site from hackers and SQL database injections.

Have you changed your database prefix using any of the method above? If yes, let us know which method did you used. Share your feedback regarding those methods here.

See also : How to Fix Error Establishing a Database Connection

One Comment

  1. WordPress is a highly customizable CMS that have been adopted by millions around the web.
    Unfortunately with the so much popularity, WordPress became a top target of many hackers who created automated scripts to target various vulnerabilities in the WordPress.
    One of the way to harden the security of your WordPress website is to change default database prefix from “wp_” to something else.
    Learn how to do that in this step by step tutorial: http://www.cloudways.com/blog/change-wordpress-database-table-prefix-manually/

Comments are closed.