wordpress 您没有足够的权限在不做任何更改的情况下访问此页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13815461/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:06:16  来源:igfitidea点击:

You do not have sufficient permissions to access this page without any change

wordpressftpadmin

提问by Kashif Waheed

I am working on Wordpress and I completed my project locally. I then moved it to my live server and did not change anything, I just made changes in the config file (database name, username and password).

我在 Wordpress 上工作,我在本地完成了我的项目。然后我将它移动到我的实时服务器并没有改变任何东西,我只是在配置文件(数据库名称、用户名和密码)中进行了更改。

Now my site is working fine on the front-end but I can't get access to the admin panel as every time it gives me the error message:

现在我的网站在前端工作正常,但我无法访问管理面板,因为每次它都给我错误消息:

You do not have sufficient permissions to access this page.

您没有足够的权限访问此页面。

Google searches indicate that most of the errors occurred due to a change in the prefix but in my case its the same as on local. Also, the permissions of my directories are 755 and that of files is 644 but still am facing the same issue.

谷歌搜索表明大多数错误是由于前缀的变化而发生的,但在我的情况下它与本地相同。此外,我的目录的权限是 755,文件的权限是 644,但仍然面临同样的问题。

How might I go about fixing this?

我该如何解决这个问题?

回答by Nikola Ivanov Nikolov

Have you changed the prefix of your database tables? I'm 90% sure, that this is your problem.

您是否更改了数据库表的前缀?我 90% 肯定,这是你的问题。

The thing is that WordPress uses the $table_prefixvariable for forming the option and usermeta keys names, where it's storing the roles and capabilities information. So once you change the prefix, but don't update your db, you get this error. Here's how to fix it - execute this SQL command through phpMyAdmin, or a different interface for interacting with your DB(you can do it with PHP as well):

问题是 WordPress 使用$table_prefix变量来形成选项和 usermeta 键名称,它存储角色和功能信息。因此,一旦您更改了前缀,但不更新您的数据库,您就会收到此错误。以下是修复它的方法 - 通过 phpMyAdmin 或其他用于与数据库交互的界面执行此 SQL 命令(您也可以使用 PHP 执行此操作):

UPDATE `{%TABLE_PREFIX%}usermeta` SET `meta_key` = replace(`meta_key`, '{%OLD_TABLE_PREFIX%}', '{%NEW_TABLE_PREFIX%}');
UPDATE `{%TABLE_PREFIX%}options` SET `option_name` = replace(`option_name`, '{%OLD_TABLE_PREFIX%}', '{%NEW_TABLE_PREFIX%}');

Where:

在哪里:

  • {%TABLE_PREFIX%}is your current $table_prefix(as set in wp-config.php)
  • {%OLD_TABLE_PREFIX%}is your previous $table_prefix
  • {%NEW_TABLE_PREFIX%}is your new(current) $table_prefix- it will most-likely be the same as your {%TABLE_PREFIX%}.
  • {%TABLE_PREFIX%}是您当前的$table_prefix(如 中设置的wp-config.php
  • {%OLD_TABLE_PREFIX%}是你以前的 $table_prefix
  • {%NEW_TABLE_PREFIX%}是您的新(当前)$table_prefix-它很可能与您的{%TABLE_PREFIX%}.

So if your old $table_prefixwas wp_test_and your new one is wp_, you would do this query:

因此,如果您的旧版本$table_prefix是 ,wp_test_而您的新版本是wp_,则可以执行以下查询:

UPDATE `wp_usermeta` SET `meta_key` = replace(`meta_key`, 'wp_test_', 'wp_');
UPDATE `wp_options` SET `option_name` = replace(`option_name`, 'wp_test_', 'wp_');


EDIT: As @Francisco Corrales noted, if you are having troubles accessing an admin page that you created(if you don't write PHP, this is not your case), you can check out this link: Wordpress Error while developing a plugin -"You do not have sufficient permissions to access this page."

编辑:正如@Francisco Corrales 所指出的,如果您在访问您创建的管理页面时遇到问题(如果您不编写 PHP,这不是您的情况),您可以查看此链接:开发插件时出现 Wordpress 错误 - “您没有足够的权限访问此页面。”



EDIT 2: As @Kasper Souren noted, you might want to add a WHERE clause to the options UPDATE query. Like so(don't remove the %after the last %}):

编辑 2:正如@Kasper Souren 所指出的,您可能希望向选项 UPDATE 查询添加 WHERE 子句。像这样(不要%在最后一个之后删除%}):

UPDATE `{%TABLE_PREFIX%}options` SET `option_name` = replace(`option_name`, '{%OLD_TABLE_PREFIX%}', '{%NEW_TABLE_PREFIX%}') WHERE option_name like '{%OLD_TABLE_PREFIX%}%';

回答by barakadam

Your problem is not with permission on directories. The fact that you see a "You do not have sufficient permissions to access this page" message means three things :

您的问题与目录权限无关。您看到“您没有足够的权限访问此页面”消息这一事实意味着三件事:

  1. you are trying to access an admin page directly but not through wp-admin (so please indicate which admin page you are trying to access),

  2. you are already logged in (otherwise you would be redirected to /wp-admin) and

  3. the area you are trying to access is reserved for a higher level of user (so you might be connecting with an editor account whereas the area is only accessible to administrators).

  1. 您正在尝试直接访问管理页面,而不是通过 wp-admin(因此请指明您要访问的管理页面),

  2. 您已经登录(否则您将被重定向到 /wp-admin)和

  3. 您尝试访问的区域是为更高级别的用户保留的(因此您可能正在连接编辑器帐户,而该区域仅供管理员访问)。

Can you tell us if your local database and the online database are the same? Can you log in properly before you see this message?

您能告诉我们您的本地数据库和在线数据库是否相同吗?您能在看到此消息之前正确登录吗?