Basically, WordPress had a default database prefix wp_ and I strongly recommend to change default prefix to the other word.
The main reason to change the prefix of the database in different installations of WordPress is to protect your WordPress database from hackers or spammers.To protect or secure your WordPress database, it is good to change its prefix to unique other keywords.
When you are installing a WordPress, you will get the option for changing the database default prefix to another one. But if you have not changed the prefix at installation time, you can change by following steps.
NOTE:Before you continue with following steps, make sure you take backup your database.
STEP 1:Edit wp-config.php
First of all,Open wp-config.php file which can be found in the WordPress root directory and replace the default prefix
wp_ to the new more secure table prefix.
1 2 3 4 5 | $table_prefix = "wp_"; //to $table_prefix = "cd1wp_"; |
Step 2: Change all WordPress table names
Next, Go to WordPress database and apply rename query to database tables to change the prefix of all tables. To rename one table at a time.
Here are Rename queries to rename the 11 tables of wordpress:
1 2 3 4 5 6 7 8 9 10 11 12 13 | Rename table wp_commentmeta to cd1wp_commentmeta; Rename table wp_comments to cd1wp_comments; Rename table wp_links to cd1wp_links; Rename table wp_options to cd1wp_options; Rename table wp_postmeta to cd1wp_postmeta; Rename table wp_posts to cd1wp_posts; Rename table wp_terms to cd1wp_terms; Rename table wp_term_relationships to cd1wp_term_relationships; Rename table wp_term_taxonomy to cd1wp_term_taxonomy; Rename table wp_usermeta to cd1wp_usermeta; Rename table wp_users to cd1wp_users; |
If there are other tables from plugins or other things then also rename those tables.
Step 3: UPDATE other Entries in tables
There will be some fields in the options and user meta tables which use wp_as a prefix. so You have to change them as well.
By executing the following query, you will get one row in the table so replace existing old prefix to new prefix.
1 2 3 | SELECT * FROM cd1wp_options WHERE option_name LIKE 'wp_user_roles'; |
NOTE: If you fail to change above prefix, you will not be able to log in afterwards with WordPress.
Finally, execute the following query, you will get some fields which use wp_ as a prefix. so You have to change them from old prefix to new prefix.Don’t miss any records from the table.
1 2 3 | SELECT * FROM cd1wp_options WHERE meta_key LIKE "%wp_%"; |
IN CLOSING
That is it, Now Test your WordPress site and to make sure everything works fine.
MUST READ:
Post Autosave Interval in WordPress
To add new URL rewrite rule in WordPress
Auto-tagging in WordPress
I hope you have enjoyed this tutorial. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.
Comments (1)