WordPress gotcha when changing wp_prefix

This seems like a straightforward change – just change “$table_prefix” in wp-config.php and rename all your db tables to match.  It works – you’ll find your site usable, guests will have no issues.  But when logging-in, you’ll find you don’t have permissions to access the dashboard (/wp-admin).  Visiting the dashboard URL gives you the message “Sorry, you are not allowed to access this page.” and your web inspector will confirm a status code of 403.

What’s going on?

Well, in the wp_options table, one key has the wp_prefix as part of its name:

wp_OLD-PREFIX_user_roles vs. wp_NEW-PREFIX_user_roles

So rename that key and you’re halfway there.

Now look in the wp_usermeta table – you will find many keys with wp_prefix as part of the name.


This is not even all of them:

Fix this in your favorite MySQL/MariaDB management tool by changing the keys (eg: wp_OLD_PREFIX_capabilities becomes wp_NEW_PREFIX_capabilities) and then logout and log back in and you will have the proper permissions.