当前位置:网站首页>【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
边栏推荐
- Pandorabox uses firewall rules to define non internet time
- 2021-09-15
- tp6调试(trace)
- 001: what is a data lake?
- First NFT platform in dfinity Ecology: impossible thoughts
- Halcon combined with C # to detect surface defects -- affine transformation (III)
- Auto. JS debugging: use the network mode of lightning simulator for debugging
- [CEGUI] log system
- 哈希表的理论讲解
- 2021-02-12
猜你喜欢

005: difference between data lake and data warehouse

Research on autojs wechat: the control IP in wechat on different versions of wechat or simulators is different.

机器学习之数据处理与可视化【鸢尾花数据分类|特征属性比较】

MySQL 7 affair

原始套接字使用

tp6调试(trace)

Create simple windowing programs using Visual Studio 2017

MYSQL的最左匹配原則的原理講解

FPGA基于DE2-115平台的VGA显示
![[CEGUI] window environment compilation](/img/be/0413fc876ffbbd40371469eee06f01.jpg)
[CEGUI] window environment compilation
随机推荐
one
How to do industry analysis
2021-03-26
UEFI edkii programming learning
SAP Hana error message sys_ XSA authentication failed SQLSTATE - 28000
哈希表的理论讲解
C # getting started series (12) -- string
CEPH performance optimization and enhancement
Auto. JS learning notes 7: JS file calls functions and variables in another JS file to solve various problems of call failure
Antique mfc/gdi+ Frame LCD display control
How high can C language reach by self-study alone?
Japanese economic foam and house price foam
[CEGUI] resource loading process
奇葩错误 -- 轮廓检测检测到边框、膨胀腐蚀开闭运算效果颠倒
5 most common CEPH failure scenarios
CLAHE in opencv for 16 bit image enhancement display
Research progress of DNA digital information storage
redis学习记录:字典(dict)源码分析
Using C language code to realize factory LCD RGB test program
Redis (II) Memory mapped data structure