mysql5.7.22查询报错
[ERROR][2019-05-25 14:48:21] org.activiti.rest.exception.ExceptionHandlerAdvice.handleOtherException(ExceptionHandlerAdvice.java:80) Unhandled exception org.springframework.jdbc.UncategorizedSQLException: ### Error querying database. Cause: java.sql.SQLException: Expression #1 of ORDER BY clause is not in SELECT list, references column 'xxx' which is not in SELECT list; this is incompatible with DISTINCT ### The error may exist in com/hbck/frame/dao/FrameWptDao.xml ### The error may involve com.hbck.frame.dao.FrameWptDao.getOption-Inline ### The error occurred while setting parameters
sql_mode配置问题
执行如下语句:
set session sql_mode= 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; set @@global.sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';注意:连接池要重置一下,即重启一下项目,再查询成功。
但重启mysql失效,依然报错。
配到my.cnf中,永久有效
[mysqld] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql #log-error = /var/log/mysql/error.log # By default we only accept connections from localhost #bind-address = 127.0.0.1 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 lower_case_table_names=1 sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
