WordPress is an open-source web publishing tool that helps you to create the website and blog of your choice. When it comes to security it offers the best, but due to the number of users and popularity, it has become the prime target for hackers and attackers to breach. It will be even easier to nuke the site if you are using the default prefix wp_ on your database. So it is important to change your WordPress Database Table Prefix to something that makes it difficult for the intruder to crack. Hope you change your Database table prefix, if not then change now by following the steps below.
Methods to Change WordPress Database Table Prefix
- Via wp-config.php
- Using SQL Query
- Rename Options and UserMeta table
- Using Plugins
How to Change Database Table Prefix Via wp-config.php
This method is used to change only the prefix of your WordPress database table and it will be applied to all tables. Launch your WordPress FTP and login to it.  Navigate to wp-config.php from the WordPress root directory.  Open the wp-config.php file in the code editor.  Locate the following line of code: $table_prefix = ‘wp_123’;  Change the Prefix wp to hk or you prefix you wish for.
Note: You can add only numbers, text, and underscores as a prefix. Once change save the changes.
How to Change Database Table Prefix using SQL Query
This method involves some SQL code which is pretty simple to understand and implement using which you can change all table names and its prefix individually. Go to cPanel of your WordPress hosting site.  Under the Database section, choose phpMyAdmin.  Now you can see the list of tables available on your WordPress site.  Click on SQL above the list of tables.  Enter the following line of code to replace and rename the table.
hk_commentmeta; RENAME table
hk_comments; RENAME table
hk_links; RENAME table
hk_options; RENAME table
hk_postmeta; RENAME table
hk_posts; RENAME table
hk_terms; RENAME table
hk_termmeta; RENAME table
hk_term_relationships; RENAME table
hk_term_taxonomy; RENAME table
hk_usermeta; RENAME table
The above mentioned is the code for 11 default WordPress tables for the additional table that added from the plugin can be replaced by adding it.
RENAME table (table name) TO (the name you wish to change); Once the name is changed, save the changes.
Rename Options and UserMeta table
Apart from the database table, two other fields that use wp as the prefix and to replace that follow the steps below.
SELECT * FROM
SELECT * FROM
How to Change Database Table Prefix Using Plugin
If you are not interested in manual coding or jumping into SQL and database kinds of stuff, then you can use the Change Table Prefix plugin and rename the database table prefix in no matter of time.
These are some of the possible ways to change the Database Table prefix and safeguard your site from intruders. Before making any changes in the database, make sure to backup your complete WordPress database file. Also, if the site is active, it is better to redirect all your site traffic to a temporary maintenance page until the changes being done. Hope this helps you change your database prefix and if you are facing any trouble let us know in the comments section below. For more WordPress tips and tricks, explore our blog.