Blog Single

31 May

How to Change the WordPress Database Prefix to Improve Security !!

WordPress is a content management application that shops your website’s contents,posts, pages, subject matters, plugins and themes in a database. A database is thestorage of the website and incorporates every single record. While installing WordPress,humans tend to depart the prefix wp_, which is the default. This makes it the target forhackers and spammers and may run automated codes for sq. Injections. The safest wayto protect your database is with the aid of changing the database prefix while setting upyour WordPress web page. In this post, you’ll learn how you can make your database safewith the aid of changing the default database prefix.

Change Table Prefix in wp-config.php

Login to your cPanel and select File Manager.

cPanel >> File Manager

ublic_html and select wp-config.php >> Right click wp-config.php and Click Edit.

Edit wp-config.php file
db prefix change

Right here, the default wp_ has been changed to wp_ test_

$table_prefix = ‘wp_test_’; 

Please note that numbers, letters, and underscores can be used as a prefix.

Change all Database Tables Name

After changing the wp-config.php file, you have to alternate it in your database.

From your CPanel, open phpMyAdmin and manipulate the panel to make right entry.

cPaenl >> phpMyAdmin

In the phpMyAdmin control panel, there are 12 WordPress tables from where you have to change the prefix manually. 

To change the prefix manually would be time-consuming. Here, you will execute a below-mentioned query to change the entire default prefix to the latest one.

Execute the below query in the SQL query window to alternate the prefix of the database at once.

RENAME table `wp_commentmeta` TO `wp_test_commentmeta`;

RENAME table `wp_comments` TO `wp_test_comments`;

RENAME table `wp_links` TO `wp_test_links`;

RENAME table `wp_options` TO `wp_test_options`;

RENAME table `wp_postmeta` TO `wp_test_postmeta`;

RENAME table `wp_posts` TO `wp_test_posts`;

RENAME table `wp_termmeta` TO `wp_test_termmeta`;

RENAME table `wp_terms` TO `wp_test_terms`;

RENAME table `wp_term_relationships` TO `wp_test_term_relationships`;

RENAME table `wp_term_taxonomy` TO `wp_test_term_taxonomy`;

RENAME table `wp_usermeta` TO `wp_test_usermeta`;

RENAME table `wp_users` TO `wp_test_users`;

Change the Options table

WordPress stores all the global options in the Options table. In this table there are some entries which also need to have their prefix changed. To retrieve a list of all the entries that are using the wp_ prefix and needs changing, use the following SQL query:

SELECT * FROM `wp_test_options` WHERE `option_name` LIKE ‘%wp_%’

Change the UserMeta table

The WordPress UserMeta table contains all the information about registered users, such as personalised settings. In this table there are also a number of entries that need to have their prefix changed. To retrieve a list of all entries that are using the wp_  prefix, use the following SQL query:

SELECT * FROM `wp_test_usermeta` WHERE `meta_key` LIKE ‘%wp_%’

NOTE:

If there are other tables created by third-party plugins, you have to change the prefix name by running the query. After changing the entire wp_ prefix, you have to check the working of your website and WordPress dashboard. Test the pages, posts, dashboard, and make sure the whole site and WordPress dashboard are working fine as before.

Now, you should make a new backup of your database just to be on the safe side.

CONCLUSION:

Securing WordPress involves securing your database. The default table prefix is well-known and targeted by hackers across the Web. Changing your prefix to something obscure and difficult to guess is an easy way to stop automated attacks, malicious scripts, and other evilness from compromising your precious database.

Please checkout our WordPress Security guide at https://tinyurl.com/scnbdvo

And remember – always keep recent backups!!!

Related Posts

Leave A Comment