Renaming table prefix on WordPress 2.9

I wanted to rename the table prefix for this blog before upgrading to WordPress 3.0. I knew about the WordPress Table Prefix Rename Plugin which claimed to work for WordPress 2.x, but I couldn’t find anyone saying they had tried it specifically on WordPress 2.9.

wordpress table rename plugin

The only thing to do was to try it myself. As stated in the documentation this plugin doesn’t actually rename the tables, it copies the tables, and gives the copies your chosen prefix. It also modifies a few entries in the new tables which refer to the tables by name. Then it modifies the prefix entry in wp-config.php.

Before using it I looked through the PHP source code to make sure I was happy with what it was going to do. And of course I made full backups of my tables just in case it all went wrong.

I disabled the WP Super Cache plugin, and deleted the cache, to make sure that after the rename I could see the actual generated blog pages, rather than pages that had previously been cached by WP Super Cache.

I also opened the phpMyAdmin control panel that my web host (1and1) uses for managing the MySQL databases.

After installing and activating the plugin I went to its setting page, typed in my chosen table prefix, and pressed ‘Generate New Tables’. After 2-3 seconds it was done. I made a copy of the SQL statements that had been used (they get displayed on screen) for reference just in case I needed them later.

Then I pressed ‘Change $table_prefix’ button. This only took a second.

To check that everything had worked I logged out of WordPress and back in. I checked a few pages on the blog as well. And I checked wp-config.php using my FTP program to make sure it had been modified. It had all worked!

Using phpMyAdmin I checked that the new tables were the same size as the old ones (taking into account any overhead in the original tables).

I’d recommend you keep the old tables until you are sure that the new ones are working fine. Wait a few weeks – or even longer before deleting them if you have space. They don’t do any harm, and act as an extra backup of your data.

Table renaming tips

  • Read the plugin source so you know what it is going to do.
  • Backup your database tables, and verify that the backup is good.
  • Set aside enough time to restore your blog from backups in case it all goes wrong.
  • Keep your original tables if you have the space. More backups are good.

2 Comments on “Renaming table prefix on WordPress 2.9”

  1. Hi Ray – this method should work on WordPress 3.1 as well. The most important thing with doing this kind of change is to have good backups (and know how to use them) before making the change. It should be straight forward, but if something goes wrong you are in for a whole load of pain!

Leave a Reply

Your email address will not be published. Required fields are marked *

Do NOT fill this !