How to Fix the “Sorry, you are not allowed to access this page.” Error After Importing a Database with a Different Prefix in WordPress

Have you recently imported a WordPress database and encountered the frustrating “Sorry, you are not allowed to access this page.” error when trying to log in or access your admin dashboard? This commonly happens when the imported database uses a different table prefix from the one set in your destination installation.

Why Does This Error Occur?

WordPress uses database table prefixes to organize and secure your data. When migrating or importing a database, if the table prefix in the imported database doesn’t match the prefix in your current WordPress installation (defined in your wp-config.php file), it can lead to permission issues and login errors, displaying the dreaded message:

A screenshot of a Safari browser encountering the "Sorry, you are not allowed to access this page." error when accessing the wp-admin of a WordPress website.

How to Quickly Fix the Error

You can resolve this issue by running a simple SQL find-and-replace query on your database, specifically targeting two key tables: wp_options and wp_usermeta.

For example, if the imported database has a prefix of edw_ and your new destination database uses the standard wp_ prefix, you should run the following SQL queries:

Update wp_usermeta:

UPDATE wp_usermeta
SET meta_key = REPLACE(meta_key, 'edw_', 'wp_')
WHERE meta_key LIKE '%edw_%';

Update wp_options:

UPDATE wp_options
SET option_name = REPLACE(option_name, 'edw_', 'wp_')
WHERE option_name LIKE '%edw_%';

Alternative Method: Using a Plugin to Update the Database

If executing SQL queries seems out of reach, or you don’t have access to do so, you can use a plugin like WP Migrate Lite to run a find-and-replace command on your database. Here’s how:

  1. Install and Activate WP Migrate Lite:
    • Navigate to your WordPress dashboard, go to Plugins > Add New, search for “WP Migrate Lite,” install it, and activate.
  2. Run the Find-and-Replace:
    • Go to Tools > WP Migrate.
    • Click on the “Find & Replace” tab.
    • Enter your old prefix (edw_) in the “Find” field and your new prefix (wp_) in the “Replace” field.
    • Click “Find & Replace” to update your database.
  3. Verify the Changes:
    • Clear your cache and refresh your admin login page.
    • Log in again to confirm that the error is resolved.

Important Tips

  • Backup First: Always back up your database before running these SQL queries.
  • Double-check Prefixes: Confirm both old and new prefixes carefully.
  • Clear Cache: After performing the update, clear your website cache and refresh the admin login page.

By following these steps, you’ll quickly regain access to your WordPress admin panel without the frustrating error message. Happy troubleshooting!



Leave a Reply

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