How to Change WordPress Database Tables Prefix for More Security

For better security, it’s better to change WordPress database tables prefix so that no one can guess it.

The database tables are the vulnerabilities which should be protected. In this tutorial, you will learn two different ways.

Before You Even Start Editing Any File

It’s always recommended to backup your WordPress website and the database before you start changing anything. The database is very sensitive and even a single wrong SQL query can break it.

You should always have a backup plan. And if possible, you should redirect your website to a temporary maintenance page.

It’s because while changing the database tables prefix, your website will go down for a while. You would be interested in knowing the different ways to backup your WordPress database.

The Things Required for Changing the Database Tables Prefix

First of all, you have to change it from the wp-config.php file from your WordPress directory. Then editing of the database will be done.

Let mention the steps.

  • Changing the tables prefix from the wp-config.php file
  • Change the tables prefix from the database
  • Update the options table
  • Update the UserMeta table

Follow these steps one by one.

#1. Changing the Tables prefix from the wp-config.php File

This file is one of the most important files of the WordPress directory because it’s responsible for making the database connection with the rest of your website.

That’s why it’s recommended to protect the wp-config.php file to secure it.

To change the database tables prefix, you have to find a code of the default tables prefix.

$table_prefix = ‘wp_’;

You will find this code if you haven’t changed the tables prefix ever before.

You can replace the default ‘wp_’ to anything you want including numbers, letters, and underscore. Make sure, you keep the underscore at the last.

Let me show you some example.

  • st23_ti_
  • gtnsl_383_
  • nts4t_
  • lik4ht_
  • tyi0ns_

You can change it like this and update the code. Let say, you choose ‘stw1_’ as the new tables prefix.

$table_prefix = ‘stw1_’;

Save the file. Now if you try to open your website then it will either show nothing or the WordPress installation page will appear.

It’s because the database credentials aren’t matching. To fix this, you have to take the next step.

#2. Change the Tables Prefix from the Database

You have to open the database using the cPanel of your web hosting.

Login the cPanel and under the databases section, open the phpMyAdmin and a new tab will appear to you.

Select the database name from the left side menu and all the database tables will get displayed. You can easily notice the default tables prefix.

There are many default tables which get created when you install WordPress for the first time. You have to change those tables.

Either you can change the prefix for each table individually or you can add the code for all.


Like what you read? Give Ravi Chahar a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.