13 Nov
Posted by SE as Security, Wordpress
|
Email This Post
|
Print This Post
If you table prefix is “wp_” or “wp1_” or even “wordpress_”, then changing it will bring your wordpress site security to a higher level.
By default fantastico installation sets “wp_” as a prefix for each wordpress table name. Since this is a known vulnerability, malicious users can exploit your data easily.
They specifically look for the wp_options table, because it will alter your wordpress site look. Through wp_options they can set the url to redirect to their sites, leaving you the impression that your site was defaced.
If you already have a wordpress site, take a look at either your config.php file or go to phpMyAdmin in cPanel to check your tables names.
// Entry in config.php showing wordpress table prefix used in the installation
$table_prefix = ‘wp_’; // Only numbers, letters, and underscores please!
Attackers can easily send malicious code using JavaScript injecting SQL targeting your wp_ based tables. To make your wordpress site really secure, change the prefix to something that is difficult to guess. I would pick something almost like a password, except you are limited here to only numbers, letters, and/or underscores.
You might want to check a plugin “wp prefix changer” written by Philipp Heinze for BlogSecurity.net. It should do the job for you. However, I had problems using it, and prefer the manual way which I already done for 2 blogs.
I strongly recommend you to do change the prefix, if it is plain wp_. Just follow the next 6 steps and you should be in good shape:
1- Take a backup
Since this is a change in your wordpress table structure, you will have to take a backup first.
In cPanel click on the “Backups” icon and click on “Generate/Download a full Backup” and proceed with a “Home Directory Backup”.
2- Edit your wp-config.php file and change
$table_prefix = ‘wp_’;
to something like
$table_prefix = ‘op2mro445_’;
3- Change all your your wordpress table names
Go to phpMyAdmin and choose your wordpress database. Click on sql menu item and enter the command to rename all your tables. Do it one table at a time.
Note: You might have more tables that start with “wp_” prefix, change all the tables.
Every time you paste one line into the SQL window, click on GO and see the table name change on your left. Keep changing the table names until all your wordpress tables have the new prefix.
Rename table wp_link2cat to op2mro445_link2cat
Rename table wp_categories to op2mro445_categories
Rename table wp_links to op2mro445_links
Rename table wp_options to op2mro445_options
Rename table wp_post2cat to op2mro445_post2cat
Rename table wp_postmeta to op2mro445_postmeta
Rename table wp_posts to op2mro445_posts
Rename table wp_usermeta to op2mro445_usermeta
Rename table wp_users to op2mro445_users
4- Edit wp_options
Then you need to edit in the op2mro445_options table ( formaly wp_options ) table
Click on the table name link and then click on “Browse” menu item.
You will see all the data stored in that table. Look under the option_name column header and change wp_user_roles to op2mro445_user_roles.
You will be able to change it by clicking on the edit button for that record.
5- Edit wp_usermeta
And finally apply changes to op2mro445_usermeta formally ( wp_usermeta)
In phpMyAdmin highlight op2mro445_usermeta link and click browse menu.
Change every value under meta_key column header, that starts with the old prefix wp_ to the new prefix op2mro445_ the number or records might be different for your web site.
I had values wp_autosave_draft_ids and wp_user_level for the field meta_key need, and changed them to the new prefix: op2mro445_autosave_draft_ids and op2mro445_user_level.
6- Done! Test your wordpress site now
It should be a lot more secure giving you the peace of mind to focus on blogging.
Oh, one more thing. Do another backup.
If I can be of any help, just let me know.
22 Responses
Jeremy
November 14th, 2007 at 7:29 am
1Awesome post Sherif.
Keep it up.
Fitz
November 15th, 2007 at 12:36 am
2Great post! I was having problems with Table Prefix changer and your method worked the first try.
Thanks!
sherif
November 15th, 2007 at 11:45 pm
3Thanks. I think it is safer to take the manual approach, because if you have an issue you would know where you stopped at.
I think using the plugin is riskier because if for any reason it stopped immaturely, you would not know what you have to clean.
Kaka
November 24th, 2007 at 5:26 pm
4ahem, this’s a nice post, but there’s something bugs? and/or problem in wp table prefix changer plugin. Some guys has reported if they can’t change their wp_prefix and always get error message: “Your User which is used to access your Wordpress Tables/Database, hasn’t enough rights (is missing ALTER-right) to alter your Tablestructure.”
actually, I had the exact same problem as them, and your method requires many time to do so, why? ’cause i’ve a bunch plugins which has been installed on my own blog, and of course it using wp_ prefix too, one of these are firestat.
but, i am successfully changing the default prefix (wp_) using my own method, see below:
01. backup your wordpress database (i’m using phpmyadmin) to an *.sql file.
02. open that *.sql file (make another copy first) using text editor, then find and replace all “wp_” prefix to “something_”.
03. now, drop all tables of your wordpress databases (don’t drop the database :D)
04. import the *.sql file which has been edited before into your wordpress databases.
05. and lastly, edit your wp-config.php file and change the $table_prefix = ‘wp_’; to $table_prefix = ’something_’;
06. in my case, all plugins will be deactivaed automatically, so login to your blog admin panel, then activated your all plugin.
07. done !
yep, it work perfectly for me.. !
Sherif
November 25th, 2007 at 10:08 am
5Great idea, thanks for your comment.
Yup, your steps will work, however I think your approach is more risky, because the owner has to completely empty and rebuild all the tables in the database.
WP 2.3.1 Tables Which Must Be Renamed | Aufklarung Journal
December 9th, 2007 at 8:25 pm
6[…] A wordpress folks, Sherif Elsisi, has explained steps is done it, you can check on his blog here: tdot-blog.com/wordpress/6-simple-steps-to-change-your-table-prefix-in-wordpress. But Sherif totally like Blogsecurity.net team, just described the wordpress primary tables that […]
Rey
March 2nd, 2008 at 4:26 pm
7Great post brother. This helped me out of a serious bind.
Rey’s last blog post..Color Me Bad: Painting Again
Protect Your Neck: Securing Your Wordpress Blog | Rey's A Point
March 2nd, 2008 at 5:01 pm
8[…] your site just because they know you have the default info installed. This site here has the best instructions yet if you can’t get it to be changed […]
9 SEO Security Tips for Wordpress to avoid being banned in Google | Antezeta Web Marketing
May 13th, 2008 at 3:40 pm
9[…] table names. There are several table prefix plugins which will do this for you, or you can follow manual instructions. Do note you may have problems with badly written plugins if they have hard-coded the table prefix […]
9 Suggerimenti per migliorare la sicurezza di Wordpress ed evitare una penale da Google | Antezeta Web Marketing
May 14th, 2008 at 9:29 am
10[…] per definire il prefisso delle tabelle che faranno questo per te, oppure è possibile seguire le istruzioni manuali. È da notare che si possono avere problemi con le estensioni (plugin) scritte male se non […]
» Blogging Tip: Is Your Blog Secure? Blog Marketing Journal
June 13th, 2008 at 6:25 pm
11[…] is very good six step guide to changing your table prefix at t-dot blog - simply follow the instructions carefully and you will safeguard your database tables. There is […]
Typolight
September 6th, 2008 at 10:32 am
12Thanks, your nice post that helped me alot.
Chris
March 1st, 2009 at 8:37 am
13Hi,
Good post. I want to do this but I’m a bit hesitant as I have the eCommerce plugin installed and it’s got a ton of its own tables. They all start with wp_ as well - are you aware if these types of plugins use the table prefix setting in the options/config files mentioned above?
Thanks!
Sherif
March 1st, 2009 at 11:02 am
14Hi Chris
No guaranty, however any well written plugin should use the setting from the config files.
You can either try to uninstall the plugin and then after the change re-install it, or just check with the plugin author about it first.
Of course, don’t forget to take a good backup before starting any change.
Regards.
Chris
March 2nd, 2009 at 5:57 am
15Fair comments - thanks Sherif!
Mark
March 5th, 2009 at 5:39 am
16Awesome post!!
The auto option didn’t work and I did NOT want to do this manually.
YOU made it sooooo simple. Just follow the steps and you’ll be successful.
Thanks so much.
brenda
March 10th, 2009 at 6:49 pm
17I am so appreciative of this short tutorial. Someone told me change my tables and admin username but was not exactly sure how to do it. I found your site and followed your six steps.
thank you for the wonderful work~!
Sherif
March 12th, 2009 at 7:14 am
18Thank you for taking a look and your comment, if you have any other questions, please let me know.
Security Check - WordPress table prefix change adds more security | Blog Design Studio
May 21st, 2009 at 6:11 am
19[…] a. Manual way of changing - Sherif has posted a wonderful and detailed tutorial that allows you to change the table prefix in 6 simple steps. […]
vg
June 21st, 2009 at 12:17 am
20Thanks! This is a great info, I’ve successfully changed my db from wp_
Miguel Guerreiro
June 21st, 2009 at 10:39 am
21Thanks, really easy tutorial. Well done.
8 Top Tips for Wordpress Theme development » James Whittaker
June 26th, 2009 at 11:04 am
22[…] this guide, I managed to change the database tables. However I could not log into the admin interface. To get […]
RSS feed for comments on this post · TrackBack URI
Leave a reply
Welcome ...
My name is Sherif Elsisi and on this blog I share my knowledge, discovery and experience with hosting issues, Webmaster tools, security and usability.
About Me | Free blog setup | Value added Web Hosting
Categories
Archives
Links
Sponsors
Calendar
Select eBooks
Most Popular Posts
Latest Posts
Your Testimonials
News Headlines
Article Headlines
Web Hosting
Wordpress
Most Commented
Tdot - Blog hosted by TdotHost | BloggingPro theme by: Design Disease | Hosting and Blogging Guide is powered by WordPress