Change WordPress Database Table Prefix Back To wp_

Here is how to change the WordPress database tables back to the default wp_ prefix.

First thing is to change the php constant table prefix in wp-config.php

Change the wp-config.php constant

$table_prefix = 'wp_';

Change the table prefixes in phpMyAdmin

Change WordPress Database Prefix
Select all WordPress Database Tables

Next open your WordPress database in phpMyadmin, select all the tables and choose the option to ‘Replace table prefix’ then in the resulting dialog box put in the from and to prefixes.

Replace Other Prefix References in the Database

There are also some other references in the tables that need to be changed in the options and usermeta tables.

Keeping our example – changing weirdprefix_ back to wp_ in the phpMyadmin SQL tab run this sql command.

Change WordPress Database Prefix Sql Command
SQL command to change other reference prefixes
update wp_usermeta set meta_key = 'wp_capabilities' where meta_key = 'weirdprefix_capabilities';
update wp_usermeta set meta_key = 'wp_user_level' where meta_key = 'weirdprefix_user_level';
update wp_usermeta set meta_key = 'wp_autosave_draft_ids' where meta_key = 'weirdprefix_autosave_draft_ids';
update wp_options set option_name = 'wp_user_roles' where option_name = 'weirdprefix_user_roles';

That’s it all done – back to the original prefix of wp_
( I realise some like to change it to add an extra security layer)

Leave all Comment