本地windows环境执行视图命令报错:
[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'book.book.category' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
翻译得到:这与sql_mode=only_full_group_by不兼容
新建查询:select @@sql_mode;
可得到结果如下:
通过命令select VERSION();
查看mysql版本:
找到mysql安装目录,找到my.ini
,在[mysqld]
下新增或修改:
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
重启mysql服务再次打开视图即可得到想要的结果
mac 下参见:https://blog.csdn.net/nadeal/article/details/90711661
linux 下参见:https://www.jianshu.com/p/1db69c552c47
注意版本,不同版本可能会有些许差别,之前可能是因为
sql_mode
参数内容不足或是多余导致mysql无法重启