解决 java.sql.SQLSyntaxErrorException: Expression

Cause: java.sql.SQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘dys_msme.scene_his_info.scene_his_id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘dys_msme.scene_his_info.scene_his_id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

修改配置文件

vi /etc/mysql/mysql.conf.d/mysqld.cnf
添加以下配置
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

重启msyql

systemctl restart mysql
 FLUSH PRIVILEGES

在docker 中永久修改
映射配置文件

volumes:
      - /workspace/config/mysql/datadir:/var/lib/mysql
      - /workspace/config/mysql/conf:/etc/mysql/conf.d
      - /workspace/config/mysql/conf/mysql.conf.d:/etc/mysql/mysql.conf.d 
      - /workspace/config/mysql/conf/my.cnf:/etc/mysql/my.cnf 
      - /workspace/config/mysql/logs:/var/log/mysql

在my.conf中添加以下代码

[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

修改当前会话sql_mode

SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE';

mysql 8.0修改mysql密码

mysql> show databases;

mysql> use mysql;

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
或者
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY '123456';

mysql> flush privileges;   --刷新MySQL的系统权限相关表

mysql> exit;
在 Ubuntu 上安装 MySQL 的完整步骤如下(支持 ​​Ubuntu 20.04/22.04/24.04​​):


​​步骤1:更新软件包并安装MySQL​​
sudo apt update
sudo apt install mysql-server -y  # 安装最新稳定版
​​关键配置与操作​​
修改配置文件:
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
找到 bind-address 并改为:
bind-address = 0.0.0.0
重启MySQL:
sudo systemctl restart mysql
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值