How can I change the WordPress database table name prefix?Submitted by Robert Abela on July 11, 2011 - 10:46 am 6 Comments
**Do not do the below change unless you are comfortable with PHPMyAdmin and making changes to MySQL. If not, ask someone who is familiar with WordPress and MySQL to assist you. Also, backup your blog; it is of utmost importance that before doing any changes to your WordPress installation or database, to backup the whole blog including the database.
WP Security Scan offers the functionality to automatically change the database table name prefix for you, so you are protected against zero day SQL injections. Some people prefer to do such change manually. Below is a detailed step by step procedure on how you can change the WordPress database table name prefixes manually.
- Backup your WordPress database to a sql file. You can do so by using the phpmyadmin (typically available from your hosting service control panel) or if you have direct access to the server, you can use MySQL command line parameters to backup the database.
- Make a copy of the WordPress database backup file (.sql) in case you would need to restore the database.
- Open the WordPress database file (*.sql) using a text editor.
- Find and replace all “wp_” prefixes to “anything_” (anything_ being any value or word you would like to use).
- Drop all database tables of your WordPress database. Make sure that the tables ONLY are dropped and not the whole database.
- Import the modified WordPress database backup file (*.sql) using PHPMyAdmin or MySQL commands. You just restored the WordPress database using new table prefixes.
- Edit your wp-config.php file (which can be found in the WordPress root directory) and replace the value ‘wp_’ in the line $table_prefix = ‘wp_’; to the new assigned table prefix.
- There is a slight chance that your plugins will be deactivated automatically after following the above procedure. In that case activate them again manually. We always recommend that before doing such a change, the plugins should be all deactivated.
Else, you can use the Database tool in WP Security Scan to AUTOMATICALLY rename the WordPress database table prefixes.
- Pingback: New version of WP Security Scan is available - WebsiteDefender.com on July 12, 2011