织梦dedecms使用Mysql8.0无法登录后台的解决办法
Posted 艾瑞巴蒂
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了织梦dedecms使用Mysql8.0无法登录后台的解决办法相关的知识,希望对你有一定的参考价值。
因mysql 8.0新制定的语句表名限制条件被dede自带的后台用户登录检查语句指定表别名所违背而引起的bug。如何解决呢?
<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">1
//只允许用户名和密码用0-9,a-z,A-Z,‘@‘,‘_‘,‘.‘,‘-‘这些字符
2
$this->userName = preg_replace("/[^0-9a-zA-Z_@!.-]/", ‘‘, $username);
3
$this->userPwd = preg_replace("/[^0-9a-zA-Z_@!.-]/", ‘‘, $userpwd);
4
$pwd = substr(md5($this->userPwd), 5, 20);
5
6
$dsql->SetQuery("SELECT admin.*,atype.purviews FROM `dede_admin` admin LEFT JOIN `dede_admintype` atype ON atype.rank=admin.usertype WHERE admin.userid LIKE ‘".$this->userName."‘ LIMIT 0,1");
7
$dsql->Execute();
8
$row = $dsql->GetObject();
</span></span>
其中SetQuery就是设定将要执行的sql语句, 下一行Execute()来执行这个设定好语句,我们从语句里面改。改成如下:
<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">1
//只允许用户名和密码用0-9,a-z,A-Z,‘@‘,‘_‘,‘.‘,‘-‘这些字符
2
$this->userName = preg_replace("/[^0-9a-zA-Z_@!.-]/", ‘‘, $username);
3
$this->userPwd = preg_replace("/[^0-9a-zA-Z_@!.-]/", ‘‘, $userpwd);
4
$pwd = substr(md5($this->userPwd), 5, 20);
5
6
$dsql->SetQuery("SELECT admi.*,atype.purviews FROM `dede_admin` admi LEFT JOIN `dede_admintype` atype ON atype.rank=admi.usertype WHERE admi.userid LIKE ‘".$this->userName."‘ LIMIT 0,1");
7
$dsql->Execute();
8
$row = $dsql->GetObject();
</span></span>
<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">1
//只允许用户名和密码用0-9,a-z,A-Z,‘@‘,‘_‘,‘.‘,‘-‘这些字符
2
$this->userName = preg_replace("/[^0-9a-zA-Z_@!.-]/", ‘‘, $username);
3
$this->userPwd = preg_replace("/[^0-9a-zA-Z_@!.-]/", ‘‘, $userpwd);
4
$pwd = substr(md5($this->userPwd), 5, 20);
5
6
$dsql->SetQuery("SELECT admi.*,atype.purviews FROM `dede_admin` admi LEFT JOIN `dede_admintype` atype ON atype.rank=admi.usertype WHERE admi.userid LIKE ‘".$this->userName."‘ LIMIT 0,1");
7
$dsql->Execute();
8
$row = $dsql->GetObject();
</span></span>
这样一来,表的别名从admin删去一个n被改成admi, 就可以正常登录后台了。
以上是关于织梦dedecms使用Mysql8.0无法登录后台的解决办法的主要内容,如果未能解决你的问题,请参考以下文章