Jianrry

“SQLSTATE[42000]: Syntax error or access violation: 1055”报错的解决方案
前言:安装完Typecho博客后,进入留言板页面,提示“Database Query Error”。打开调试模式后...
扫描右侧二维码阅读全文
28
2018/07

“SQLSTATE[42000]: Syntax error or access violation: 1055”报错的解决方案

前言:

安装完Typecho博客后,进入留言板页面,提示“Database Query Error”。打开调试模式后,出现了下面的报错信息,最后在@sffxzzp的帮助下终于解决了。

报错信息:

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #3 of SELECT list is not in GROUP BY

 clause and contains nonaggregated column 'jianrry.com.typecho_comments.url' which is not functionally 

dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by 

Typecho_Db_Query_Exception: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #3 of 

SELECT list is not in GROUP BY clause and contains nonaggregated column 'jianrry.com.typecho_comments.url'

 which is not functionally dependent on columns in GROUP BY clause; this is incompatible with 

sql_mode=only_full_group_by in /data/wwwroot/jianrry.com/var/Typecho/Db/Adapter/Pdo.php:105 Stack trace: 

#0 /data/wwwroot/jianrry.com/var/Typecho/Db.php(354): Typecho_Db_Adapter_Pdo->query('SELECT COUNT(`a...', 

Object(PDO), 1, 'SELECT') #1 /data/wwwroot/jianrry.com/var/Typecho/Db.php(384): Typecho_Db-

>query(Object(Typecho_Db_Query), 1) #2 /data/wwwroot/jianrry.com/usr/themes/handsome/functions.php(807): 

Typecho_Db->fetchAll(Object(Typecho_Db_Query)) #3 

/data/wwwroot/jianrry.com/usr/themes/handsome/guestbook.php(36): getFriendWall() #4 

/data/wwwroot/jianrry.com/var/Widget/Archive.php(2022): require_once('/data/wwwroot/j...') #5 

/data/wwwroot/jianrry.com/var/Typecho/Router.php(138): Widget_Archive->render() #6 

/data/wwwroot/jianrry.com/index.php(25): Typecho_Router::dispatch() #7 {main}

解决方案:

关闭MySQL的严格模式

操作步骤:

1.编辑etc/my.cnf(请提前进行备份!)

2.在文件的末尾添加下面的代码:

[mysqld]  
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

3.重启MySQL服务

service mysqld restart

参考资料:

Disable ONLY_FULL_GROUP_BY

最后修改:2019 年 06 月 03 日 09 : 15 AM
如果觉得我的文章对你有用,请随意赞赏

发表评论