Archive for the ‘Wordpress’ Category

Wordpress wp table prefix change

Sunday, May 17th, 2009

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.

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

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 = ‘pomegranates1445_’;

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 pomegranates1445_link2cat
Rename table wp_categories to pomegranates1445_categories
Rename table wp_links to pomegranates1445_links
Rename table wp_options to pomegranates1445_options
Rename table wp_post2cat to pomegranates1445_post2cat
Rename table wp_postmeta to pomegranates1445_postmeta
Rename table wp_posts to pomegranates1445_posts
Rename table wp_usermeta to pomegranates1445_usermeta
Rename table wp_users to pomegranates1445_users

4- Edit wp_options

Then you need to edit in the pomegranates1445_options table ( formerly 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 pomegranates1440_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 pomegranates1445_usermeta formally ( wp_usermeta)

In phpMyAdmin highlight pomegranates1445_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 pomegranates1445_ 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: pomegranates1445_autosave_draft_ids and pomegranates1445_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.

If this helps you please link to my site.