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:
- your sFTP username and password (How to locate your login credentials)
- Your database username and password (How to locate your login credentials)
- WordPad or TextEdit (plain text editors usually installed on your computer)
- To export your database (how to “dump” (backup) your WordPress database)
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:
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).
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 CRUX.
Step 7 – Open your wp-config.php file and update your table prefix to the new prefix. Click Save.
- GUI diff programs