Change DB Prefix WordPress retroactively

When running a WordPress website, it can sometimes make sense to change the DB prefix. By default, the prefix is set to wp_. Since this is known to everyone who works with WordPress, the site is vulnerable to hacking if you keep the default prefix.

How to change the DB prefix in WordPress #

Important preparation:

Secure the database!

You should include this in your considerations:

Changing the DB prefix makes it more difficult for potential hackers to attack the site. But not all hackers can be prevented from attacking the site anyway!

Manual change of the DB prefix #

You will need access to PHP MyAdmin and FTP access to your installation.

Edit the wp-config.php

To do this, download the wp-config.php file locally via ftp. Then open this file and look for the line that contains the DB prefix. The line should normally look like this

$table_prefix = 'wp_';

change the wp_ here to a prefix of your choice, e.g. mywebsite_.

Now save the wp-config.php and upload it back to the original location.

Changes in the database

Now rename all WordPress tables in your database.

From the designations

  • wp_commentmeta
  • wp_comments
  • wp_links
  • wp_options
  • wp_postmeta
  • wp_posts
  • wp_terms
  • wp_term_relationships
  • wp_term_taxonomy

are now

  • mywebsite_commentmeta
  • mywebsite_comments
  • mywebsite_links
  • mywebsite_options
  • mywebsite_postmeta
  • mywebsite_posts
  • mywebsite_terms
  • my_website_term_relationships
  • my_website_term_taxonomy

As you can see, the wp_ was simply replaced by meinewebsite_. And already we have a new DB prefix.

Now you should test your WordPress website to see if everything is still working.

If you choose the manual method, don't forget to deactivate all plug-ins first and only reactivate them after renaming.

Changing the DB prefix with a plugin #

Instead of the manual method, you can also use a plugin. So far, we have made many prefix changes with the plugin BROZZME. The plugin works reliably and renames all prefixes reliably. With the plugin you can also look up the prefix later without having to log into the database or look in wp-config.php.


In any case, you should always test the installation after all work has been carried out to see if it is still running. It is imperative that you always make a complete backup of everything you do, just in case something goes wrong.