Sometimes you may get a notice in your WordPress saying. Sorry, you are not allowed to access this page when you try to log into your admin panel. Some people whenever they see such they think their WordPress site has been hacked or has crashed.
Relax your WordPress has not crashed!
Keep Reading; you will see the reason for such error notice.
In most cases, this particular error message on WordPress admin login attempts has to do with MySQL database. It occurs mostly when more than one WordPress site or project in the same database – all with same table prefix – irrespective of the database name.
I can’t say how many WordPress projects are expected to be in the same database with the same table prefix. But it’s obvious the issue has to do with database and not WordPress. Hope you will agree with me after we are done solving this issue.
If you have only one WordPress installed on your server then you may consider troubleshooting your WordPress, but if you have more than one WordPress on your server first confirm to see if they bear the same table prefix, if they do then you will find your solution here, but if they don’t just troubleshoot your WordPress.
WordPress made it clear as a comment in wp-config.php that “You can have multiple installations in one database if you give each a unique prefix.”
If you ignore WordPress warning, then there is a very high tendency of getting this error message – “Sorry, you are not allowed to access this page” when you try to log in.
How to avoid this issue
Note that WordPress default table prefix is “wp_,” you can use the default table prefix in your first WordPress installation, but if you must install another WordPress on the same database then you are expected change the table prefix, i.e. from “wp_” to “wp2_” or even to “myblog_.” WordPress gives you the privilege to edit its table prefix during installation. Whichever table prefix you choose while installing WordPress it will be the table prefix of each of the tables in the database.
How to fix this issue
The only way to fix this is to do it manually. You may think of backing up your entire WordPress site including the database then install another WordPress while you change the table prefix and restore your website, but am sorry but this definitely will not work because, the database backup still have a different table prefix name, so it can’t be successful rather it will complicate issues.
We love issues when they are easy to fix,
But it’s easy, follow the steps below you will see the solution you are seeking.
Steps To Resolve “WP-ADMIN: ‘Sorry, you are not allowed to access this page'” Online
Before you start this process, please make sure that you first backup your site on your control panel to enable the return to your site previous status if this process did not work for you. You can also choose to download a copy of your database as your backup.
1) Open the “file manager” of your site Control panel,
2) Open the affected site folder in the file manager,
3) Look for a PHP file named as “wp-config”,
4) Open the file and look for a line written as “$table_prefix = ‘wp_'”,
5) Change ‘wp_’ to the new table prefix you choose i.e “$table_prefix = ‘wpblog_'” then click on “save”,
6) Make sure you don’t forget your new table prefix, which is now “wpblog_.”
7) Go back to your control panel home page and click to open “phpMyAdmin.”
8) Once it opens, look for the site database name on the left and click to open it.
9) Once it opens you will see the list of tables on the left with names such as “wp_commentmeta”, “wp_comments”, “wp_links”, “wp_options” and so on.
See image below
10) Click to open SQL and enter the command to rename all your tables. Do it one table at a time.
RENAME table `wp_commentmeta` TO `wpblog_commentmeta`; RENAME table `wp_comments` TO `wpblog_comments`; RENAME table `wp_links` TO `wpblog_links`; RENAME table `wp_options` TO `wpblog_options`; RENAME table `wp_postmeta` TO `wpblog_postmeta`; RENAME table `wp_posts` TO `wpblog_posts`; RENAME table `wp_terms` TO `wpblog_terms`; RENAME table `wp_term_relationships` TO `wpblog_term_relationships`; RENAME table `wp_term_taxonomy` TO `wpblog_term_taxonomy`; RENAME table `wp_usermeta` TO `wpblog_usermeta`; RENAME table `wp_users` TO `wpblog_users`;
11) Next click on the new modified table “wpblog_options” which was previously called “wp_options”
12) After it opens click on “Browse” to view all the data stored in that table.
13) Under the “option_name” column header you will have to change “wp_user_roles” to “wpblog_user_roles“.
Note: wp_user_roles may not appear on the first page in most cases so you may need to look for it in different pages. If this is not done, login will not be possible.
Alternatively, you can make use of this command in the SQL
SELECT * FROM `wpblog_options` WHERE `option_name` LIKE '%wp_%'
14) In the next step, you will also need to click on “wpblog_usermeta,” which was previously called ‘wp_usermeta.”
15) Click on “Browse” and change every value under meta_key column which has the old table prefix wp_ to the new table prefix wpblog_
Also, alternatively you can make use of this command in the SQL
SELECT * FROM `wpblog_usermeta` WHERE `meta_key` LIKE '%wp_%'
And that is it; it’s as simple as that.
For those test running WordPress on a local server, to resolve this issue, first look for the directory where your WordPress local site is located, the directory may differ depending on the local server you’re using. But there should be a shortcut to open your project directory from your local server.
For users of wamp server, you will see the shortcut known as “www directory,” after which, follow every other step as explained above.
Another usage of WordPress table prefix
Changing WordPress table prefix is not only to correct the above issue, but it can also be used to keep your WordPress more secured to make it very difficult for hackers to access.
Imagine changing your WordPress table prefix from wp_ to something like xwct_
Of course, the new table prefix is almost impossible to guess by human or robot; it will shield your WordPress site.
Watch the video also to see how to change WordPress table prefix.
I hope this information helps you.
- How To Troubleshoot & Debug WordPress Website Without Issues
- How to Disable or Limit WordPress Post Revisions
- Fix – PHP Memory Limit Error In WordPress
- How to Install WordPress on Local Server