Can’t Access the Dashboard After Changing WordPress Database Prefix
It is a frequently suggested WordPress security tip to update your default WordPress database table prefixes. However, upon doing so you now appear to have lost access to your WordPress Dashboard backend.
Attempts to login to your WordPress website Dashboard backend simply results in a redirect to your homepage with a very limited WordPress Admin bar. Furthermore, any attempts to directly access your Dashboard backend via the “wp-admin” url presents you with the following error message:
Sorry, you are not allowed to access this page.
The issue is that your WordPress website database has the previous database table prefix stored within one or more of its table records. You will have to manually update these in order to restore your Dashboard admin access. Not a big deal, using your favorite database tool (we recommend phpMyAdmin) we will show you how to quickly fix this in this article.
Resolving Admin Dashboard Access
If you haven’t already done so, be sure to have obtained a backup of your entire website and database. Or better yet, try this out on a staging server first. Don’t have a staging server? Let us set up a staging server for you.
- We assume you’ve already implemented the new table prefix on your WordPress database.
- If you haven’t already done so update the table prefix variable, “$table_prefix“, within your wp-config.php file to the new prefix.
- Run a manual search and replace on your _options table for your old prefix (see below).
- Run a manual search and replace on your _usermeta table for your old prefix (see below).
Modify the OPTIONS Table
Search your “X_options” table (where X is your new prefix) for any instances of the old table prefix. To save you time, here is an example of the SQL query:
SELECT * FROM ‘X_options’ WHERE ‘option_name’ LIKE ‘%wp_%’
The purpose of this is to find any options that began with the old and assumed “wp_” prefix and replace them with your new table prefix. If you are having issues accessing your WordPress website backend you would want to update the option_name field which contains wp_user_roles in particular.
Modify the USERMETA Table
Search your “X_usermeta” table (where X is your new prefix) for any instances of the old table prefix. To save you time, here is an example of the SQL query:
SELECT * FROM ‘X_usermeta’ WHERE ‘meta_key’ LIKE ‘%wp_%’
The purpose of this is to find any options that began with the old and assumed “wp_” prefix and replace them with your new table prefix.
Check for Website Access
That should do it! Your should now have access to your WordPress Admin Dashboard again. Be sure to double check that everything functions correctly. It is also suggested to login as any other registered member roles to check their functionality.
If everything works as it should, you’ve successfully updated your WordPress website’s default database prefix.
Conclusion
I welcome your thoughts, questions or suggestions on my article on gaining access to your WordPress website Admin Backend after table prefix update.
You may support my work by sending me a tip using your Brave browser or by sending me a one time donation using your credit card.
Let me know if you found any errors within my article or if I may further assist you by answering any additional questions you may have.
I owe you a coffee!
Happy to have helped Ridge! Thanks for letting me know the article helped you.