How to Change the WordPress Database Prefix to Improve Security

WordPress Database is sort of a mind on your whole WordPress website as a result of each single data is saved in there thus making it hacker’s favourite goal. Spammers and hackers run automated codes for SQL injections. Nicely, sadly many individuals overlook to change the database prefix whereas they set up WordPress. This makes it simpler for hackers to plan a mass assault by concentrating on the default prefix wp_. The neatest manner you possibly can defend your database is by altering the database prefix which is very easy to do on a website that you’re establishing. Nevertheless it takes just a few steps to alter the WordPress database prefix correctly on your established website with out utterly messing it up.


We suggest that you simply backup your WordPress Database earlier than you carry out something recommended on this tutorial. It is very important hold day by day backups of your website, we suggest BackupBuddy plugin for doing that. Subsequent factor we suggest is that you simply redirect your guests to a brief upkeep web page.

Change Desk Prefix in wp-config.php

Open your wp-config.php file which is positioned in your WordPress root listing. Change the desk prefix line from wp_ to one thing else like this wp_a123456_

So the road would seem like this:

$table_prefix  = 'wp_a123456_';

Be aware: You’ll be able to solely change it to numbers, letters, and underscores.

Change all Database Tables Title

You’ll want to entry your database (most definitely by way of phpMyAdmin), after which change the desk names to the one we laid out in wp-config.php file. If you’re utilizing the cPanel WordPress internet hosting, then you will discover the phpMyAdmin hyperlink in your cPanel. Take a look at the picture beneath:

There are a complete of 11 default WordPress tables, so altering them manually can be ache.

That’s why to make issues sooner, we’ve a SQL question that you need to use.

RENAME table `wp_commentmeta` TO `wp_a123456_commentmeta`;
RENAME table `wp_comments` TO `wp_a123456_comments`;
RENAME table `wp_links` TO `wp_a123456_links`;
RENAME table `wp_options` TO `wp_a123456_options`;
RENAME table `wp_postmeta` TO `wp_a123456_postmeta`;
RENAME table `wp_posts` TO `wp_a123456_posts`;
RENAME table `wp_terms` TO `wp_a123456_terms`;
RENAME table `wp_termmeta` TO `wp_a123456_termmeta`;
RENAME table `wp_term_relationships` TO `wp_a123456_term_relationships`;
RENAME table `wp_term_taxonomy` TO `wp_a123456_term_taxonomy`;
RENAME table `wp_usermeta` TO `wp_a123456_usermeta`;
RENAME table `wp_users` TO `wp_a123456_users`;

You could have so as to add strains for different plugins that will add their very own tables within the WordPress database. The thought is that you simply change all tables prefix to the one that you really want.

You May Also Like : How to Display WordPress Post Thumbnails with Captions

The Choices Desk

We have to search the choices desk for some other fields that’s utilizing wp_ as a prefix, so we are able to change them. To ease up the method, use this question:

SELECT * FROM `wp_a123456_options` WHERE `option_name` LIKE '%wp_%'

This can return quite a lot of outcomes, and you should go one after the other to alter these strains.

UserMeta Desk

Subsequent, we have to search the usermeta for all fields that’s utilizing wp_ as a prefix, so we are able to change it. Use this SQL question for that:

SELECT * FROM `wp_a123456_usermeta` WHERE `meta_key` LIKE '%wp_%'

Variety of entries might fluctuate on what number of plugins you’re utilizing and such. Simply change all the things that has wp_ to the brand new prefix.

Backup and Performed

You at the moment are prepared to check the positioning. For those who adopted the above steps, then all the things needs to be working high quality. Now, it is best to make a brand new backup of your database simply to be on the secure aspect.

If you liked this article, make sure to hit the bell for getting our latest updates and share this article with your friends in every social media platforms.

1 thought on “How to Change the WordPress Database Prefix to Improve Security”

  1. Pingback: How to Create Additional Image Sizes in WordPress

Leave a Comment

Your email address will not be published. Required fields are marked *