How to Change WordPress Database Table Prefix? Print

  • 0

You will see the default table prefix as 'wp_;' if you have a WordPress website. However, some users may require changing the prefix for various reasons. It is pertinent to mention that it is easy for hackers to identify and attack your WordPress if your table prefix is 'wp_';. But if you change the prefix, it becomes difficult for hackers to break into your WordPress.

To change the database table prefix for your WordPress, you can refer to the following steps – 

1. Open File Manager, locate the file wp-config.php, and open it.

2. Locate a line with the following entry – 

$table_prefix = 'wp_';

 

3. Replace the table prefix from 'wp_' with your preference.

Here we have changed it to demo_

$table_prefix = 'demo_';

4. Open the phpMyAdmin and go to your WordPress database. 

5. Check all the tables and click on Replace table prefix option. 

6. Click on Continue

It will change all the existing table prefixes to demo_.





 

7. WordPress may use the old table prefix from some of the settings stored in the database. You can make the changes given below to replace the new prefix. 

8. Inside phpMyAdmin, click on the SQL button. 

9. Copy-paste the following line and replace the NEWPREFIX and OLDPREFIX per your requirement.

We have used demo_ as a new prefix.

update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_capabilities' where meta_key = 'OLDPREFIX_capabilities';
update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_user_level' where meta_key = 'OLDPREFIX_user_level';
update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_autosave_draft_ids' where meta_key = 'OLDPREFIX_autosave_draft_ids';
update NEWPREFIX_options set option_name = 'NEWPREFIX_user_roles' where option_name = 'OLDPREFIX_user_roles';

10. Once you are ready with the replacement, click the Go button. 





You have successfully changed the WordPress Database Table prefix.



Was this answer helpful?

« Back

chat