How to change WordPress database table prefix? Print

  • 0

If you have a wordpress website, you will see the default table prefix as 'wp_;'. However, some users may require to change the prefix due to various reasons. Also, if your table prefix is 'wp_'; it is easy for hackers to identify and attack your Wordpress. If you change the prefix, it can be hard for them to break in.

Please refer to the following steps to change the database table prefix for your Wordpress. 

  1. Open your 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_' to your required one. Here we have changed it to demo_.

    $table_prefix = 'demo_';
  4. Open the phpMyAdmin and go to your Wordpress database. Check all the tables and click on replace table prefix option. Click on continue, and it will change all the existing table prefixes to demo_.





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

  6. Inside phpMyAdmin, click on the SQL button. 

  7. Copy-paste the following line and replace the NEWPREFIX and OLDPREFIX as 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';
  8. Once you are ready with the replacement, click on the Go button. 





    You have successfully change the Wordpress Database table prefix.

Was this answer helpful?

« Back
Sign up for a newsletter

chat