By default, WordPress installation will have “wp_” as the table prefix which is quite vulnerable, malicious users can exploit your data quite easily. So, changing the prefix to something stronger and unique will add up higher security and safe from malicious users. It is better to change the prefix when you are installing the WordPress but if you have already installed the WordPress using default settings then here is our solution for you.
To check what is the existing the table prefix for your WordPress installation, just take a look at your “wp-config.php” file and find these lines:
* WordPress Database Table prefix.
* You can have multiple installations in one database if you give each a unique
* prefix. Only numbers, letters, and underscores please!
$table_prefix = ‘wp_’;
So, here you can see “wp_” is the table prefix.
Here, are the few simple steps with the help of which you can change the table prefix to something else:
1) Backup your database
As we are making changes to the WordPress table prefix, I strongly recommend you to take a backup of the database so that we are on safe side. To take a backup, if you are using cpanel then just go to phpmyadmin and select your database and export the whole database and have it on safe place so incase of any trouble we can restore the backup.
2) Change the table prefix to something strong on wp-config.php
$table_prefix = ‘wp_’;
to something secure like
$table_prefix = ‘tb3yx8z_’;
3) Now, go to phpmyadmin and select your WP database. Now, click on SQL menu item to execute mysql query to rename all your tables.
MySQL Query sample:
Rename table wp_commentmeta to tb3yx8z_commentmeta;
Rename table wp_comments to tb3yx8z_comments;
Rename table wp_links to tb3yx8z_links;
Rename table wp_options to tb3yx8z_options;
Rename table wp_postmeta to tb3yx8z_postmeta;
Rename table wp_posts to tb3yx8z_posts;
Rename table wp_terms to tb3yx8z_terms;
Rename table wp_term_relationships to tb3yx8z_term_relationships;
Rename table wp_term_taxonomy to tb3yx8z_term_taxonomy;
Rename table wp_usermeta to tb3yx8z_usermeta;
Rename table wp_users to tb3yx8z_users;
Similarly, there might be other tables that start with ‘wp_’ prefix. Now, you must be able to write MySql query to rename other tables.
4) Now, you need to edit tb3yx8z_options table.
Browse table “tb3yx8z_options” and search for “wp_user_roles” under option_name column field. Just rename “wp_user_roles” to “tb3yx8z_user_roles”.
5) Now, you need to edit tb3yx8z_usermeta table.
Browse table “tb3yx8z_usermeta” and change every value under meta_key column header, that starts with the old prefix “wp_” to the new prefix “tb3yx8z_” the number or records might be different for your web site.
For example: you will find “wp_capabilities” so change it to”tb3yx8z_capabilities” and similarly for others.
And that’s it, we have successfully changed the table prefix from “wp_” to “”tb3yx8z_”. Now, test your website and also, login to admin panel and test if everything is alright. If anything goes wrong then restore the backup and then, follow one by one step from the top. If you still have problem with it then please feel free to comment below.
Hope this will be a great help.