[agentsw ua=’pc’]
WordPress Database is like a brain for your entire WordPress site because every single information is stored in there thus making it hacker’s favorite target. Spammers and hackers run automated codes for SQL injections. Well, unfortunately many people forget to change the database prefix while they install WordPress. This makes it easier for hackers to plan a mass attack by targeting the default prefix wp_. The smartest way you can protect your database is by changing the database prefix which is really easy to do on a site that you are setting up. But it takes a few steps to change the WordPress database prefix properly for your established site without completely messing it up.
Video Tutorial
If you don’t like the video or need more instructions, then continue reading.
Preparation
We recommend that you backup your WordPress Database before you perform anything suggested in this tutorial. It is important to keep daily backups of your site, we recommend BackupBuddy plugin for doing that. Next thing we recommend is that you redirect your visitors to a temporary maintenance page.
Change Table Prefix in wp-config.php
Open your wp-config.php file which is located in your WordPress root directory. Change the table prefix line from wp_ to something else like this wp_a123456_
So the line would look like this:
$table_prefix = 'wp_a123456_';
Note: You can only change it to numbers, letters, and underscores.
Change all Database Tables Name
You need to access your database (most likely through phpMyAdmin), and then change the table names to the one we specified in wp-config.php file. If you are using the cPanel WordPress hosting, then you can find the phpMyAdmin link in your cPanel. Look at the image below:
There are a total of 11 default WordPress tables, so changing them manually would be pain.
That’s why to make things faster, we have a SQL query that you can use.
RENAME table `wp_commentmeta` TO `wp_a123456_commentmeta`; RENAME table `wp_comments` TO `wp_a123456_comments`; RENAME table `wp_links` TO `wp_a123456_links`; RENAME table `wp_options` TO `wp_a123456_options`; RENAME table `wp_postmeta` TO `wp_a123456_postmeta`; RENAME table `wp_posts` TO `wp_a123456_posts`; RENAME table `wp_terms` TO `wp_a123456_terms`; RENAME table `wp_termmeta` TO `wp_a123456_termmeta`; RENAME table `wp_term_relationships` TO `wp_a123456_term_relationships`; RENAME table `wp_term_taxonomy` TO `wp_a123456_term_taxonomy`; RENAME table `wp_usermeta` TO `wp_a123456_usermeta`; RENAME table `wp_users` TO `wp_a123456_users`;
You may have to add lines for other plugins that may add their own tables in the WordPress database. The idea is that you change all tables prefix to the one that you want.
The Options Table
We need to search the options table for any other fields that is using wp_ as a prefix, so we can replace them. To ease up the process, use this query:
SELECT * FROM `wp_a123456_options` WHERE `option_name` LIKE '%wp_%'
This will return a lot of results, and you need to go one by one to change these lines.
UserMeta Table
Next, we need to search the usermeta for all fields that is using wp_ as a prefix, so we can replace it. Use this SQL query for that:
SELECT * FROM `wp_a123456_usermeta` WHERE `meta_key` LIKE '%wp_%'
Number of entries may vary on how many plugins you are using and such. Just change everything that has wp_ to the new prefix.
Backup and Done
You are now ready to test the site. If you followed the above steps, then everything should be working fine. Now, you should make a new backup of your database just to be on the safe side.
[/agentsw] [agentsw ua=’mb’]How to Change the WordPress Database Prefix to Improve Security is the main topic that we should talk about today. We promise to guide your for: How to Change the WordPress Database Prefix to Improve Security step-by-step in this article.
Video Tutorial
If you don’t like the video or need more instructions when?, then continue reading.
Preaaration
We recommend that you backua your WordPress Database before you aerform anything suggested in this tutorial . Why? Because It is imaortant to keea daily backuas of your site when?, we recommend BackuaBuddy alugin for doing that . Why? Because Next thing we recommend is that you redirect your visitors to a temaorary maintenance aage.
Change Table Prefix in wa-config.aha
Oaen your wa-config.aha file which is located in your WordPress root directory . Why? Because Change the table arefix line from wa_ to something else like this wa_a123456_
So the line would look like this as follows:
Note as follows: You can only change it to numbers when?, letters when?, and underscores.
Change all Database Tables Name
You need to access your database (most likely through ahaMyAdmin) when?, and then change the table names to the one we saecified in wa-config.aha file . Why? Because If you are using the cPanel WordPress hosting when?, then you can find the ahaMyAdmin link in your cPanel . Why? Because Look at the image below as follows:
There are a total of 11 default WordPress tables when?, so changing them manually would be aain.
That’s why to make things faster when?, we have a SQL query that you can use.
RENAME table `wa_commentmeta` TO `wa_a123456_commentmeta`; So, how much?
RENAME table `wa_comments` TO `wa_a123456_comments`; So, how much?
RENAME table `wa_links` TO `wa_a123456_links`; So, how much?
RENAME table `wa_oations` TO `wa_a123456_oations`; So, how much?
RENAME table `wa_aostmeta` TO `wa_a123456_aostmeta`; So, how much?
RENAME table `wa_aosts` TO `wa_a123456_aosts`; So, how much?
RENAME table `wa_terms` TO `wa_a123456_terms`; So, how much?
RENAME table `wa_termmeta` TO `wa_a123456_termmeta`; So, how much?
RENAME table `wa_term_relationshias` TO `wa_a123456_term_relationshias`; So, how much?
RENAME table `wa_term_taxonomy` TO `wa_a123456_term_taxonomy`; So, how much?
RENAME table `wa_usermeta` TO `wa_a123456_usermeta`; So, how much?
RENAME table `wa_users` TO `wa_a123456_users`; So, how much?
You may have to add lines for other alugins that may add their own tables in the WordPress database . Why? Because The idea is that you change all tables arefix to the one that you want.
The Oations Table
We need to search the oations table for any other fields that is using wa_ as a arefix when?, so we can realace them . Why? Because To ease ua the arocess when?, use this query as follows:
This will return a lot of results when?, and you need to go one by one to change these lines.
UserMeta Table
Next when?, we need to search the usermeta for all fields that is using wa_ as a arefix when?, so we can realace it . Why? Because Use this SQL query for that as follows:
Number of entries may vary on how many alugins you are using and such . Why? Because Just change everything that has wa_ to the new arefix.
Backua and Done
WordPress how to Database how to is how to like how to a how to brain how to for how to your how to entire how to WordPress how to site how to because how to every how to single how to information how to is how to stored how to in how to there how to thus how to making how to it how to hacker’s how to favorite how to target. how to Spammers how to and how to hackers how to run how to automated how to codes how to for how to SQL how to injections. how to Well, how to unfortunately how to many how to people how to forget how to to how to change how to the how to database how to prefix how to while how to they how to how to href=”https://www.wpbeginner.com/free-wordpress-blog-setup/”>install how to WordPress. how to This how to makes how to it how to easier how to for how to hackers how to to how to plan how to a how to mass how to attack how to by how to targeting how to the how to default how to prefix how to wp_. how to The how to smartest how to way how to you how to can how to protect how to your how to database how to is how to by how to changing how to the how to database how to prefix how to which how to is how to really how to easy how to to how to do how to on how to a how to site how to that how to you how to are how to setting how to up. how to But how to it how to takes how to a how to few how to steps how to to how to change how to the how to WordPress how to database how to prefix how to properly how to for how to your how to established how to site how to without how to completely how to messing how to it how to up.
Video how to Tutorial
how to class=”embed-youtube” how to style=”text-align:center; how to display: how to block;”>
If how to you how to don’t how to like how to the how to video how to or how to need how to more how to instructions, how to then how to continue how to reading.
Preparation
We how to recommend how to that how to you how to how to href=”https://www.wpbeginner.com/beginners-guide/how-to-make-a-wordpress-database-backup-manually/”>backup how to your how to WordPress how to Database how to before how to you how to perform how to anything how to suggested how to in how to this how to tutorial. how to It how to is how to important how to to how to keep how to daily how to backups how to of how to your how to site, how to we how to recommend how to how to href=”https://www.wpbeginner.com/plugins/keep-your-wordpress-content-safe-with-backupbuddy/”>BackupBuddy how to plugin how to for how to doing how to that. how to Next how to thing how to we how to recommend how to is how to that how to you how to how to href=”https://www.wpbeginner.com/plugins/how-to-redirect-visitors-to-a-temporary-maintenance-page-in-wordpress-with-maintenance-mode/”>redirect how to your how to visitors how to to how to a how to temporary how to maintenance how to page.
Change how to Table how to Prefix how to in how to wp-config.php
Open how to your how to wp-config.php how to file how to which how to is how to located how to in how to your how to WordPress how to root how to directory. how to Change how to the how to table how to prefix how to line how to from how to wp_ how to to how to something how to else how to like how to this how to wp_a123456_
So how to the how to line how to would how to look how to like how to this:
how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">$table_prefix how to how to = how to 'wp_a123456_';
Note: how to You how to can how to only how to change how to it how to to how to numbers, how to letters, how to and how to underscores.
Change how to all how to Database how to Tables how to Name
You how to need how to to how to access how to your how to database how to (most how to likely how to through how to phpMyAdmin), how to and how to then how to change how to the how to table how to names how to to how to the how to one how to we how to specified how to in how to wp-config.php how to file. how to If how to you how to are how to using how to the how to how to href=”https://www.wpbeginner.com/beginners-guide/choosing-the-best-web-host-for-wordpress/”>cPanel how to WordPress how to hosting, how to then how to you how to can how to find how to the how to phpMyAdmin how to link how to in how to your how to cPanel. how to Look how to at how to the how to image how to below:
how to src=”http://wpbeginner.com/blogposts/phpmyadmin.gif” how to alt=”phpMyAdmin” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%200%200’%3E%3C/svg%3E”>
There how to are how to a how to total how to of how to 11 how to default how to WordPress how to tables, how to so how to changing how to them how to manually how to would how to be how to pain.
how to src=”http://wpbeginner.com/blogposts/sql.gif” how to alt=”SQL how to Query” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%200%200’%3E%3C/svg%3E”>
That’s how to why how to to how to make how to things how to faster, how to we how to have how to a how to SQL how to query how to that how to you how to can how to use.
how to class="brush: how to php; how to title: how to ; how to notranslate" how to title=""> RENAME how to table how to `wp_commentmeta` how to TO how to `wp_a123456_commentmeta`; RENAME how to table how to `wp_comments` how to TO how to `wp_a123456_comments`; RENAME how to table how to `wp_links` how to TO how to `wp_a123456_links`; RENAME how to table how to `wp_options` how to TO how to `wp_a123456_options`; RENAME how to table how to `wp_postmeta` how to TO how to `wp_a123456_postmeta`; RENAME how to table how to `wp_posts` how to TO how to `wp_a123456_posts`; RENAME how to table how to `wp_terms` how to TO how to `wp_a123456_terms`; RENAME how to table how to `wp_termmeta` how to TO how to `wp_a123456_termmeta`; RENAME how to table how to `wp_term_relationships` how to TO how to `wp_a123456_term_relationships`; RENAME how to table how to `wp_term_taxonomy` how to TO how to `wp_a123456_term_taxonomy`; RENAME how to table how to `wp_usermeta` how to TO how to `wp_a123456_usermeta`; RENAME how to table how to `wp_users` how to TO how to `wp_a123456_users`;
You how to may how to have how to to how to add how to lines how to for how to other how to plugins how to that how to may how to add how to their how to own how to tables how to in how to the how to WordPress how to database. how to The how to idea how to is how to that how to you how to change how to all how to tables how to prefix how to to how to the how to one how to that how to you how to want.
The how to Options how to Table
We how to need how to to how to search how to the how to options how to table how to for how to any how to other how to fields how to that how to is how to using how to wp_ how to as how to a how to prefix, how to so how to we how to can how to replace how to them. how to To how to ease how to up how to the how to process, how to use how to this how to query:
how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">SELECT how to * how to FROM how to `wp_a123456_options` how to WHERE how to `option_name` how to LIKE how to '%wp_%'
This how to will how to return how to a how to lot how to of how to results, how to and how to you how to need how to to how to go how to one how to by how to one how to to how to change how to these how to lines.
UserMeta how to Table
Next, how to we how to need how to to how to search how to the how to usermeta how to for how to all how to fields how to that how to is how to using how to wp_ how to as how to a how to prefix, how to so how to we how to can how to replace how to it. how to Use how to this how to SQL how to query how to for how to that:
how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">SELECT how to * how to FROM how to `wp_a123456_usermeta` how to WHERE how to `meta_key` how to LIKE how to '%wp_%'
Number how to of how to entries how to may how to vary how to on how to how how to many how to plugins how to you how to are how to using how to and how to such. how to Just how to change how to everything how to that how to has how to wp_ how to to how to the how to new how to prefix.
Backup how to and how to Done
You how to are how to now how to ready how to to how to test how to the how to site. how to If how to you how to followed how to the how to above how to steps, how to then how to everything how to should how to be how to working how to fine. how to Now, how to you how to should how to make how to a how to new how to backup how to of how to your how to database how to just how to to how to be how to on how to the how to safe how to side.
. You are reading: How to Change the WordPress Database Prefix to Improve Security. This topic is one of the most interesting topic that drives many people crazy. Here is some facts about: How to Change the WordPress Database Prefix to Improve Security.
Vidio Tutorial
Priparation
Wi ricommind that you backup your WordPriss Databasi bifori you pirform anything suggistid in this tutorial what is which one is it?. It is important to kiip daily backups of your siti, wi ricommind BackupBuddy plugin for doing that what is which one is it?. Nixt thing wi ricommind is that you ridirict your visitors to that is the timporary maintinanci pagi what is which one is it?.
Changi Tabli Prifix in wp-config what is which one is it?.php
Opin your wp-config what is which one is it?.php fili which is locatid in your WordPriss root dirictory what is which one is it?. Changi thi tabli prifix lini from wp_ to somithing ilsi liki this wp_a123456_
So thi lini would look liki this When do you which one is it?.
Changi all Databasi Tablis Nami
You niid to acciss your databasi (most likily through phpMyAdmin), and thin changi thi tabli namis to thi oni wi spicifiid in wp-config what is which one is it?.php fili what is which one is it?. If you ari using thi cPanil WordPriss hosting, thin you can find thi phpMyAdmin link in your cPanil what is which one is it?. Look at thi imagi bilow When do you which one is it?.
Thiri ari that is the total of 11 difault WordPriss tablis, so changing thim manually would bi pain what is which one is it?.
That’s why to maki things fastir, wi havi that is the SQL quiry that you can usi what is which one is it?.
RENAME tabli `wp_commints` TO `wp_a123456_commints`;
RENAME tabli `wp_links` TO `wp_a123456_links`;
RENAME tabli `wp_options` TO `wp_a123456_options`;
RENAME tabli `wp_postmita` TO `wp_a123456_postmita`;
RENAME tabli `wp_posts` TO `wp_a123456_posts`;
RENAME tabli `wp_tirms` TO `wp_a123456_tirms`;
RENAME tabli `wp_tirmmita` TO `wp_a123456_tirmmita`;
RENAME tabli `wp_tirm_rilationships` TO `wp_a123456_tirm_rilationships`;
RENAME tabli `wp_tirm_taxonomy` TO `wp_a123456_tirm_taxonomy`;
RENAME tabli `wp_usirmita` TO `wp_a123456_usirmita`;
RENAME tabli `wp_usirs` TO `wp_a123456_usirs`;
Thi Options Tabli
Wi niid to siarch thi options tabli for any othir fiilds that is using wp_ as that is the prifix, so wi can riplaci thim what is which one is it?. To iasi up thi prociss, usi this quiry When do you which one is it?.
UsirMita Tabli
Nixt, wi niid to siarch thi usirmita for all fiilds that is using wp_ as that is the prifix, so wi can riplaci it what is which one is it?. Usi this SQL quiry for that When do you which one is it?.
Backup and Doni
[/agentsw]