While upgrading some outdated sites to the latest version of WordPress (currently 2.3.3), I ran across this error:
WordPress database error: [Table 'DB_NAME.wp_terms' doesn't exist]
When I ignored the error and continued to the admin panel, I noticed that there were no categories listed, and all the posts were set to the “uncategorized” category (though even this was not listed on the Manage -> Categories page).
The reason for this error is that WP 2.3.x does not use the wp_categories table; it uses wp_terms and wp_terms_taxonomy instead. The upgrade script is supposed to move the data from the former to the latter, but something was preventing it from doing so successfully.
A search of the WordPress codex revealed some important reminders, but no help:
- Always back up your database before attempting an upgrade
- Always disable all plugins before attempting an upgrade
- Always revert to the default “Kubrick” theme before attempting an upgrade (because many themes now contain custom functions that can interfere with the upgrade process)
Fortunately, I’d done backups, as I always do. However, I must admit to being somewhat spoiled with WordPress upgrades, as this is the first significant difficulty I’ve ever encountered with an upgrade (other than incompatible template tags and plugins). This is a chilling reminder that, no matter how well things have gone in the past, doing a backup is NOT optional; it’s essential.
After trying everything I could think of, I recalled a forum post that suggested commenting out (or deleting) these two lines in the wp-config.php file:
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', 'utf8');
You can comment them out by preceding them with two forward slashes:
//define('DB_CHARSET', 'utf8');
//define('DB_COLLATE', 'utf8');
Certain earlier versions of WP shipped with these lines, though you may not have them at all.
I restored my database from the backup, used PHPMyAdmin to deactivate all the plugins and to set the theme to ‘default’, and ran the upgrade script again (by visiting mysite.tld/wp-admin).
This did it, and I was able to re-activate my plugins and theme. Problem solved.
