当前位置:网站首页>Mysql 5.7 into the pit
Mysql 5.7 into the pit
2022-08-09 02:03:00 【Robin Luo Bing】
Environment: win10, PHPstudy, mysql5.7.26
I. Question prompt:
1. Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
p>2. Invalid default value for 'created_time'
Second, where Baidu found the problem:
ONLY_FULL_GROUP_BY:
NO_ZERO_IN_DATE,NO_ZERO_DATE:
Three, the idea of solving the problem: Since it is a high-level version, since it is a normative behavior, why should the restriction be lifted?Two ways
1. Cancel restrictions
A, the cure method
If you don't know where to set the mysql configuration in your own environment, you can query it with the following command
Execute mysql --help in the CMD command to find the configuration path (windows is my.ini, linux is my.cnf)
Default options are read from the following files in the given order:
Translation: Default options read from the following files in the given order
C:\Windows\my.ini C:\Windows\my.cnf C:\my.ini C:\my.cnf D:\phpstudy_pro\Extensions\MySQL5.7.26\my.ini D:\phpstudy_pro\Extensions\MySQL5.7.26\my.cnf
In my own environment, I only found D:\phpstudy_pro\Extensions\MySQL5.7.26\my.ini, but did not find the setting of sql_mode
So add the setting at the end of [mysqld] of my.ini (remember that it is not the last of the entire setting of my.ini, otherwise it will not take effect. After setting, restart mysql to take effect) sql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Then query sql_mode and find that it is the set value. The doubt is that if it is not set in this way, the value of sql_mode can also be found out. Where is it called?
B. Symptomatic method: do the following settings in the mysql command, it will be invalid after restarting
set @@sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
2. Standard sql syntax
A, ONLY_FULL_GROUP_BY is to strengthen the SQL specification, and its purpose is to make the results of the SQL query more in line with the specification and more accurate.
For the GROUP BY aggregation operation, if the column in the SELECT does not appear in the GROUP BY, then this SQL is invalid because the column is not in the GROUP BY clause.In short, the column following the SELECT must be included in the column following the GROUP BY.Such as:
select a,b from table group by a,b,c; (correct)
select a,b,c from table group by a,b; (wrong)
This configuration will make GROUPThe BY statement environment has become very narrow, so this configuration is generally not added
B, NO_ZERO_DATE & NO_ZERO_IN_DATE
Insert `created_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Insert time',
Modify to:
`created_time` timestamp NOT NULL DEFAULT '1970-01-01 08:00:01' COMMENT 'Insert time',
Note: The East Eighth District needs to add 8 hours, no matter whether the system time is UTC or CST, if it is CST, you need to set the default-time-zone in my.ini, I haven't tried it, my win10 systemis UTC +8 time zone
Because the default time value is set to: 0000-00-00 00:00:00, no problem has been found so far, so remove NO_ZERO_IN_DATE and NO_ZERO_DATE in my.ini, there is no need for such a specification.There is no need to set in my.ini: default-time-zone='+08:00', just default directly
It is set to:
sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Four, other
1. Login
Windows login to mysql, first switch to the path of mysql.exe, such as:
cd D:\phpstudy_pro\Extensions\MySQL5.7.26\bin
Execute: mysql -p 3306 -h 127.0.0.1 -u root -p root
2. View sql_mode: select @@sql_mode
3. Set system_time_zone (system environment time zone, mysql configuration time zone, session time zone)
A. System environment time zone: check the time zone mysql command: show variables like '%time_zone%'; I can see here that mysql adopts the system time zone setting
B. Session time zone:
set time_zone = '+8:00'; Change the time zone of the current session to East 8th zone, namely Beijing time
flush privileges; After executing the above SQL statement, if you want the time zone to take effect immediately, you also need to execute this statement
C, mysql configuration time zone: modify the configuration file: open the my.ini file, search for default-time-zone, and modify the value if it exists.If it does not exist, you can add a line after character-set-server: default-time-zone='+8:00'
Reference URL:
http://www.manongjc.com/article/16878.html
https://www.jianshu.com/p/3dbccdef6031 Clear mysql time zone
https://jingyan.baidu.com/article/2fb0ba40d170dc00f2ec5fed.html View windows time zone
边栏推荐
- spdlog日志库的封装使用
- Docker redis master-slave replication setup, the container cannot be started?
- 史上最猛“员工”,疯狂吐槽亿万富翁老板小扎:那么有钱,还总穿着同样的衣服!
- How js implements array deduplication (7 kinds)
- 全文翻译:EDPB数据保护影响评估(DPIA:Data Protection Impact Assessment)指南
- Codeforces Round #809 (Div. 2)A~D1
- String compression
- final
- 2022护眼产品展,北京眼健康展,眼科医学展,近视矫正设备展
- LeetCode每日两题01:有序数组的平方 (均1200道)方法:双指针
猜你喜欢

力扣刷题记录9.1-----24. 两两交换链表中的节点

Introduction to LVGL (based on v8.1-8.2)

Image denoising based on edge enhancement Diffusion 】 (cEED) and Coherence Enhancing coursing together (cCED) filter to realize image denoising matlab code

Observer pattern

LeetCode每日两题02:轮转数组 (均1200道)

makefile file compilation

德语翻译-德语在线批量翻译软件

D. Tournament Countdown

etcd实现大规模服务治理应用实战

如何在EasyDSS中使用ffmpeg实现点播视频的拼接与合成?
随机推荐
软件测试技术之如何编写测试用例(5)
谷歌翻译下载-免费谷歌翻译软件下载
d初化模板构造器
2022护眼产品展,北京眼健康展,眼科医学展,近视矫正设备展
全文翻译:EDPB关于VVA(虚拟语音助理)中处理个人数据的指南02/2021
软件测试的调用接口怎么调用,逻辑是什么?
日文翻译-在线免费日文翻译软件
Phenomenon 1 during RF debugging
Go-11 - Process Control
Difference between KQL and Lucene
Proe/Creo智能硬件产品结构设计要点「干货分享」
js实现数组去重的方式(7种)
[机缘参悟-65]:《兵者,诡道也》-6-孙子兵法解读-并战计
How to install ngrok in Synology system (Synology 6.X version)
Image denoising based on edge enhancement Diffusion 】 (cEED) and Coherence Enhancing coursing together (cCED) filter to realize image denoising matlab code
在树莓派上使用cpolar(番外篇2)
Group DETR:分组一对多匹配是加速DETR收敛的关键
The Best Open Source Web Application Firewall to Protect Your Web Applications
JDBC technology (2) - set up common sql and configuration files
OpenMLDB + Jupyter Notebook:快速搭建机器学习应用