How to modify Database Table Prefix in WordPress

How to modify Database Table Prefix in WordPress

In this article, we’ll go through how to modify your WordPress installation’s database table prefix.

Although we advise altering it, WordPress’s database table prefix by default is ‘wp_’. This is due to the fact that WordPress tables are regularly targeted by hackers because your database stores all of your login information. By changing the prefix, entry will be more challenging for them.

Three locations require you to alter the table prefix:

Step 1: Edit wp-config.php to change the table prefix.
Step 2: In the database, alter the table prefix.
Step 3: Take the previous prefix off of all references.

Step 1: Edit wp-config.php to change the table prefix.

  1. Find the wp-config.php file and check the box to choose it.
  2. Find the following entry:
     $table_prefix = 'wp_';

    wp-config

  3. Change ‘wp_’ to something else; in this instance, ‘icw_’ was used instead:
    $table_prefix = 'icw_';
  4. Then Save this file.

Step 2: In the database, alter the table prefix.

  1. Utilize PhpMyAdmin to access your database.
  2. The left menu’s database selection can be selected to see all tables.
  3. You should have 12 total tables; choose all of those that begin with wp_.
  4. Replace table prefix may be found by clicking With selected, which brings up a drop-down option.
  5. The new name, in this case icw_, should go in the To-field and wp_ should go in the From-field.
  6. To make the modification, click Continue.php my-admin

Also read: Fixing The 500 Internal Server Error In WordPress

Step 3: Take the previous prefix off of all references.

WordPress still uses the old table prefix in some settings that are saved in your database. You must swap these out with your new prefix to complete the prefix change.

  1. At the top of the screen, in the menu, select the SQL tab.
  2. The following commands should be copied and pasted:
    update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_commentmeta' where meta_key = 'OLDPREFIX_commentmeta';
    update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_comments' where meta_key = 'OLDPREFIX_comments';
    update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_links' where meta_key = 'OLDPREFIX_links';
    update NEWPREFIX_options set option_name = 'NEWPREFIX_postmeta' where option_name = 'OLDPREFIX_postmeta';

    php admin

  3. You should use your own old and new prefix in place of OLDPREFIX and NEWPREFIX. As in the following illustration where wp_ has been replaced with icw_:
    update icw_usermeta set meta_key = 'icw_commentmeta' where meta_key = 'wp_commentmeta';
    update icw_usermeta set meta_key = 'icw_comments' where meta_key = 'wp_comments';
    update icw_usermeta set meta_key = 'icw_links' where meta_key = 'wp_links';
    update icw_options set option_name = 'icw_options' where option_name = 'wp_options';

    php my admin

  4. For the commands to be executed and the change to be finalized, click Go.

That’s it. WordPress tables’ prefix has been modified as of late.


Jayesh Patel
Author
Jayesh Patel

Jayesh Patel is a Professional Web Developer & Designer and the Founder of InCreativeWeb.

As a highly Creative Web/Graphic/UI Designer - Front End / PHP / WordPress / Shopify Developer, with 14+ years of experience, he also provide complete solution from SEO to Digital Marketing. The passion he has for his work, his dedication, and ability to make quick, decisive decisions set him apart from the rest.

His first priority is to create a website with Complete SEO + Speed Up + WordPress Security Code of standards.



Explore

Related Articles

21st November, 2024

Advantages of Business Web Development

18th November, 2024

How to delete your cache and force a browser refresh?

16th November, 2024

How to Manage Website Technical Debt for Long-Term Success?