当前位置:网站首页>#mysql错误01#
#mysql错误01#
2022-08-06 01:17:00 【核电机组】
现象:mysql 查询出现 "this is incompatible with sql_mode=only_full_group_by"错误解决方案。
原因:这个错误发生在mysql 5.7 版本及以上版本会出现的问题:
mysql 5.7版本默认的sql配置是:sql_mode="ONLY_FULL_GROUP_BY",这个配置严格执行了"SQL92标准"。
很多从5.6升级到5.7时,为了语法兼容,大部分都会选择调整sql_mode,使其保持跟5.6一致,为了尽量兼容程序。
在sql执行时,出现该原因:
简单来说就是:输出的结果是叫target list,就是select后面跟着的字段,还有一个地方group by column,就是
group by后面跟着的字段。由于开启了ONLY_FULL_GROUP_BY的设置,所以如果一个字段没有在target list
和group by字段中同时出现,或者是聚合函数的值的话,那么这条sql查询是被mysql认为非法的,会报错误。
解决方案:
1:修改配置文件
修改mysql配置文件,通过手动添加sql_mode的方式强制指定不需要ONLY_FULL_GROUP_BY属性,
my.cnf位于etc文件夹下,vim下光标移到最后,添加如下:vim /etc/mysql.cnf
sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
2:重启mysql
如图所示:

3:其他:
3.1:查看mysql
ps -aux | grep mysql
或者
netstat -ano | grep 3306
whereis mysql 查看目录
3.2:修改密码
mysqld --user=root 强制root启动
忘记密码:
->(mysql 5.7设置的密码中必须至少包含一个大写字母、一个小写字母、一个特殊符号、一个数字,
密码长度至少为8个字符)
->在/etc/my.cnf文件中【mysqld】后面 加入skip-grant-tables,让mysql可以免密码登录 mysql -uroot
之后分别执行如下语句完成密码修改:
mysql> use mysql;
mysql> update user set authentication_string=password("NewPassword") where user="root";
或
mysql> alter user "root"@"localhost" identified by "NewPassword";
mysql> flush privileges;
mysql> show variables like '%password%'; --查看密码策略 (validate_password_policy low/medium)
mysql> set global validate_password_policy=low 密码验证策略改成low,只检查密码长度
退出重启mysql服务
systemctl restart mysqld (service mysqld restart/stop/start)
可以查看初始密码 cat /var/log/mysql.log | grep -i password
mysql -u root -pxxxxxx
修改完成
一般情况下 Linux 服务器默认安装 MySQL 的数据库表名是区分大小写的,如果CentOS上安装的 MySQL 不支持表名区分大小下,则按照如下方法操作即可:
用 root 登录,修改vim /etc/my.cnf (注意:以实际 my.cnf 配置文件路径为准)
在 [mysqld] 节点下,加入一行: lower_case_table_names=1
3.3:外网访问设置
mysql -u root -p
mysql>use mysql;
mysql>update user set host ="%" where user ="root";
mysql>flush privileges;
边栏推荐
- transceiver toolkit使用说明
- 几种常见SQL分页方式效率比较
- PAT 甲级 A1087 All Roads Lead to Rome
- 直播回放含PPT下载|基于Flink & DeepRec构建Online Deep Learning
- What is a man-in-the-middle attack?
- The miniPCIe interface CAN card quickly expands the CAN channel for the industrial computer
- Vernacular Machine Learning - Convolutional Neural Network CNN
- (3.2) Metasploit kali - the exploit 】 【 basis (under) : MSF terminal using process
- 多线程-线程调度
- EasyCVR通过进程启动无报错,但是自动退出该如何解决?
猜你喜欢

VsCode:用户代码片段 / 自定义代码片段

typescript75 - create your own type declaration files (provide declarations for existing js)

Two file types in typescript70-ts

The difference between session and cookie

How to view code comments in Idea Modified by?

Kubernetes scheduler optimization

J9数字论:Layer2的解决方案科普

typescript73-创建自己的类型声明文件(项目内共享类型)

SOAP协议学习和使用

ResNet论文及实现
随机推荐
新版本的特性
OpenWrt之kmod内核不兼容分析
电子元件品牌与标识
BugKu:Web
【mysql】--记一次delete删除语句使用别名的坑
计算S=a+aa+…+aa…a
How can el-table's data be turned into a picture plus text button?
高数_复习_第2章:一元函数微分学
OpenWrt之Kernel version hash 的那些事
map(自动排序的pair)——STL
Lateral federal study - gradient security polymerization
数据开发的经验
Live playback including PPT download | Build Online Deep Learning based on Flink & DeepRec
Flutter tabbar set text background, do not delay
Civil law common sense summary 1
golang pprof 实战
Kubernetes内存泄露怎么玩
datatables 封装传给后台的参数以及拆分穿回来的参数
datatables encapsulates the parameters passed to the background and the parameters that are split and passed back
typescript74-创建自己的类型声明文件(为已有js提供声明文件)