当前位置:网站首页>【MySQL】sql_ Model mode
【MySQL】sql_ Model mode
2022-06-12 10:12:00 【Wang Rushuang】
The reason for the problem is
Today, Xiaobian encountered such a problem , The database code on the server can run normally , But after importing the database to the local database, the local database code cannot be run , Report the following error :
The one that will report an error sql Statements are taken out and executed separately sql, Report the same question , But execute this on the server alone sql No problem. , So I checked online , It's a version problem .
see mysql Database version :SELECT VERSION() , The server version is 5.6.26, Local version is 5.7.22, The reason is because : stay MySQL5.7 after ,sql_mode The default is ONLY_FULL_GROUP_BY,SQL Statement failed ONLY_FULL_GROUP_BY Semantic check so error report
Problem analysis :
ONLY_FULL_GROUP_BY:ONLY_FULL_GROUP_BY requirement select The columns queried in the statement must be explicit ( The same is true of other statements ). With SQL sentence select columes from table group by list For example :columns Must be Aggregation function Or must be group by The expression after list in , Otherwise, it will also report an error .insert、update、delete Statements will report errors ( But it doesn't affect SQL Execution of statements ), Because the query operation will also be performed before the execution of these three statements
Illustrate with examples :
SELECT count(1) FROM customer GROUP BY `name`; The SQL Successful implementation , because count Is an aggregate function ;
SELECT * FROM customer GROUP BY `name`; The SQL Execution failure , because * Contains the primary key id, and group by The expression after does not contain id
SELECT name FROM customer GROUP BY `name`; The SQL Successful implementation , because name Included in group by In the following expression
SELECT name, contact FROM customer GROUP BY `name`; The SQL Execution failure , because contact Not included in group by In the following expression
Solution :
1. View local sql_mode:SELECT @@sql_mode
2. modify sql_mode
In the local mysql Found under installation directory my.ini, Query the contents sql_mode Remove the value ONLY_FULL_GROUP_BY Assign a value to sql_mode Value , restart mysql Service to take effect ( But I don't have it here my.ini file , But there is one my.ini.txt Text , The contents and my.ini Content is the same , Baidu learned that my.ini You have to build it yourself , So I built one by myself my.ini, take my.ini.txt Copy contents to recent files , Then set the sql_mode value )
You can also use set @@sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' Change this service , But just restart mysql Service this setting will be invalidated
边栏推荐
- markdown_ Picture side by side scheme
- Code implementation of hash table based on linear detection
- Halcon combined with C # to detect surface defects -- affine transformation (III)
- List of computer startup shortcut keys
- 在线电路仿真以及开源电子硬件设计介绍
- JVM (III) Virtual machine performance monitoring & fault handling tool
- Circuitbreaker fuse of resilience4j -- Measurement of circuitbreakermetrics index
- Value investment
- Enumerate all USB device codes
- 7-13 underground maze exploration (adjacency table)
猜你喜欢

优质好书助成长 猿辅导携四大出版社推荐“暑期好书”

Theoretical explanation of hash table

Qt自定义窗口圆角

MySQL 4 Database table storage structure & tablespace

High quality and good books help guide apes and recommend "good summer books" with the four major publishers

2021-03-26

In 2026, the capacity of China's software defined storage market will be close to US $4.51 billion

UE4_ Explore the method of creating background scenes with ready-made resources
![[DDS] ddsi-rtps specification](/img/fe/16b835e3e4a8ff71ab3dbc4b9c4d2a.jpg)
[DDS] ddsi-rtps specification
![Data processing and visualization of machine learning [iris data classification | feature attribute comparison]](/img/a3/1d181b9dd5268e13cc276a78862d1f.png)
Data processing and visualization of machine learning [iris data classification | feature attribute comparison]
随机推荐
Redis (II) Memory mapped data structure
Quickly build oncyber io
7-4 网红点打卡攻略(dfs)
用于图像处理的高性能计算框架
How to implement Web3.0 and digital fashion?
In 2026, the capacity of China's software defined storage market will be close to US $4.51 billion
CLAHE in opencv for 16 bit image enhancement display
【系统分析师之路】第十八章 复盘系统安全分析与设计
UEFI edkii programming learning
7-13 地下迷宫探索(邻接表)
7-4 network red dot punch in strategy (DFS)
Pandorabox uses firewall rules to define non internet time
Research on autojs wechat: the control IP in wechat on different versions of wechat or simulators is different.
Using C language code to realize factory LCD RGB test program
MySQL v Index and algorithm
004:aws data Lake solution
Yarn scheduling
Checkpoint of the four cornerstones of Flink
HALCON联合C#检测表面缺陷——仿射变换(三)
Auto. JS learning note 9: basic methods such as using the script engine, starting the script file with the specified path, and closing