I’ve been working on a set of scripts to backup the wordpress instances on my server. While structuring these scripts I realized that I hadn’t structured my WP installs consistently. I had played around with using table prefixes and hosting multiple WP instances in a single database but eventually I just broke them out into unique databases for simplicity.
The table prefixes persisted however and while I was poking around I decided to rename the tables dropping the prefixes. What I didn’t count on is that some values in the
options tables are prepended with the table prefix from the
wp-config.php. Without fixing up these values in the databse your site will function normally, but the admin interface will only show an error message:
You do not have sufficient permissions to access this page.
The database values that need to be fixed up are some entries in the
meta_key column of the
usermeta table and the
option_name column of the
options table. Let’s assume that your prefix is
pre_, that you’ve already removed the prefix from your database and that you now want to fix up these values. The following SQL commands will remove your old prefix from these tables:
UPDATE usermeta SET meta_key = REPLACE(meta_key,'pre_',''); UPDATE options SET option_name = REPLACE(option_name,'pre_','');