mysql5.7报异常 incompatible with sql_mode=only_full_group_by

之前一直用的mysql5.4.  发现创建视图不支持子查询。 比如说要创建一个视图,里面需要关联大量表,并用到了子查询, 这样就创建不成功。

相同的创建视图语句在5.7里面就可以成功。

测试环境安装了个5.7。 在上面执行SQL语句的时候老是保下面这个错误

[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'xxx.xxx.id' which is not functionally 
dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

网上搜了下,需要改下5.7的默认模式配置。 下面是我的一些操作【windows上面】

Step1. 进入管理员模式的cmd,先停掉mysql的服务

net stop mysql

Step2. 修改mysql文件夹下面的my.ini文件(如果没有的话,就创建一个,内容如下)

[mysqld]

# These are commonly set, remove the # and set as required.
basedir = E:\mysql-5.7
datadir = E:\mysql-5.7\data
port = 3306
# server_id = .....
 
 
 sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Step3.上面改完后,启动mysql服务

net start mysql

猜你喜欢

转载自www.cnblogs.com/bingyangzhang/p/10254449.html