您没有足够的权限在没有任何更改的情况下访问此页面 [英] You do not have sufficient permissions to access this page without any change

查看:155
本文介绍了您没有足够的权限在没有任何更改的情况下访问此页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Wordpress,并在本地完成了我的项目。然后我把它移到了我的活动服务器上,并没有改变任何东西,我只是对配置文件(数据库名称,用户名和密码)进行了修改。



现在我的网站在前端工作正常,但无法访问管理控制台,因为每次它都会显示错误消息:


您无权访问此页面。




Google的搜索表明,大部分错误都是由于前缀的变化而发生的,但在我的情况下与本地相同。另外,我的目录的权限是755,文件的权限是644,但仍面临同样的问题。



我该如何解决这个问题?

解决方案

改变了你的数据库表的前缀?我90%确定,这是你的问题。

问题在于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%}');

其中:


  • {%TABLE_PREFIX%} 是您当前的 $ table_prefix (如 wp -config.php

  • {%OLD_TABLE_PREFIX%} 是您之前的 $ table_prefix

  • {%NEW_TABLE_PREFIX%} 是您的新(当前) $ table_prefix - 它最可能与您的 {%TABLE_PREFIX%} 相同。

>

所以如果你的旧的 $ 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_');






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






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

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


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).

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.

How might I go about fixing this?

解决方案

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

The thing is that WordPress uses the $table_prefix variable 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):

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%}.

So if your old $table_prefix was wp_test_ and your new one is wp_, you would do this query:

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."


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 %}):

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

这篇关于您没有足够的权限在没有任何更改的情况下访问此页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆