WordPress is a content management system that stores your website’s content, posts, pages, themes, and plugins in a database. A database is the storage of the website and contains every single information. While installing WordPress, people tend to leave the prefix wp_, which is the default. This makes it the target for hackers and spammers and can run automated codes for SQL injections. The safest way to protect your database is by changing the database prefix while setting up your WordPress site. In this tutorial, you will learn how you can make your database safe by changing the default database prefix. It is always recommended to make a full backup of your website before making changes to your database.
Click File Manager to open the WordPress directory.
Click public_html and locate wp-config.php. Right click wp-config.php and Click Edit.
Search for the following line of code and modify it with the choice of your prefix.
$table_prefix = 'test_';
Here, the default wp_ has been changed to test_
Only numbers, letters and underscores can be used as a prefix name.
You can access it through phpMyAdmin from your cPanel. From your cPanel, Click phpMyAdmin to open the phpMyAdmin control panel. Look at the image below:
There are 12 WordPress tables, changing the prefix manually would be time consuming. Here, you will execute a query which will automatically change all the default prefix name to the name of your choice.
RENAME table`wp_commentmeta`TO`test_commentmeta`; RENAME table`wp_comments`TO`test_comments`; RENAME table`wp_links`TO`test_links`; RENAME table`wp_options`TO`test_options`; RENAME table`wp_postmeta`TO`test_postmeta`; RENAME table`wp_posts`TO`test_posts`; RENAME table`wp_terms`TO`test_terms`; RENAME table`wp_termmeta`TO`test_termmeta`; RENAME table`wp_term_relationships`TO`test_term_relationships`; RENAME table`wp_term_taxonomy`TO`test_term_taxonomy`; RENAME table`wp_usermeta`TO`test_usermeta`; RENAME table`wp_users`TO`test_users`;
Execute the above query in the SQL query window to change the prefix of the database at once.
You might want add lines for plugins that have their own tables in the database.
Congratulations, You have successfully secured your database from hackers and spammer who are waiting to attack using the default database prefix. Always remember to keep the latest backup. It is always easy to restore to a backup if something goes wrong.
Check out these top 3 WordPress hosting services:
- Click here to get the best wordpress hosting specialized for wordpress.