How to change your WordPress Database Table Prefixes

Changing your WordPress table name prefixes may be required during a migration. Many installations of WordPress use a table prefix of ‘wp_’. Tables beginning with a known prefix like wp_, make it much easier for attackers to maliciously alter your database, as they will know the names of all of the WordPress tables in your database. Changing the table prefix to a random string makes it much much harder for an attacker to execute such an attack.

You will need:

Important: When doing the find and replace step, make sure you only find and replace table prefixes and do not inadvertently replace strings of text which are not table prefixes. This can happen, for example, with WooCommerce installations which include a string in the product tables relating to images.

Step by Step Instructions:

First - make a backup copy of your database dump on your local machine - and call it something like database-dump.orig , then:

Step 1 – Open your database dump in your Text Editor.

Step 2 – Perform a Search and Replace on your current table prefix (in this example ‘wp_’ and replace it with a random string of characters).

Step 2:a

To make 100% sure you have only changed your database table prefix and nothing else, you can now use a graphical diff program to easily check the changes you have made, by comparing your edited version of the database dump to the original database dump you called database-dump.orig. When you are sure you have only changed the table prefix, it's then OK to proceed to the next step.

Step 3 – Login to your database and save your current database as a backup.

Step 4 – Drop your current database.

Step 5 – Import your updated database file.

Step 6 – Login to your FTP client using the login credentials listed in your Control Panel.

Step 7 – Open your wp-config.php file and update your table prefix to the new prefix. Click Save.

GUI diff programs