MySQL error: this is incompatible with sql_mode = only_full_group_by

tags: mysql  java

Error scenario

Today, I have a project that I just came down on my computer. When I log in to enter the home page, I reported a string of this is incompatible with sql_mode = only_full_group_by error, I am sure that there will be this mistake before the company's computer, I At the beginning, I thought it was MySQL version, so I became a 5.7.16 version of my own 5.7.33 and the company's remote database. The error is still, so after a series of findings, finally solved, now to integrate sharing A look at my problem.

wrong reason

When using the group by statement above, this is this is incompatible with sql_mode = only_full_group_rmode error, which is due to the configuration of MySQL5.7 or above, default sql_mode = "only_full_group_by", can be written in the query:

select @@GLOBAL.sql_mode;

The result of querying is

only_full_group_by

This requires the field of SELECT lookups to be included behind the group By, below is example

select a,b from table group by a; (×)

select a,b from table group by a,b,c; (√)

The field of Group By can be more than SELECT, and can not be less than SELECT

 

Solution

Temporary modification

Enter in the query

set @@GLOBAL.sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION;

This method will fail when restarting mySQL service.

2. Permanent modification

Under the root of MySQL, find my.ini files, if not, and other named INI files, such as My-Default.ini or MySQL.ini,Retain! Don't delete or replace!Otherwise, when you restart MySQL, you will not open the service, copy the existing profile to the current directory, and renamed My.ini, so that the root directory will have two profiles.

Then configure the following line under the [MySQLD] column.

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

Let's put a specific content of my my.ini file.

[mysql]

# Set the MYSQL client default character set

default-character-set=utf8

[mysqld]

# Set 3306 port

port = 3306

# Set the mysql installation directory

basedir=D:\Tools\MySQL\mysql-5.7.16-winx64

# Set the storage directory of the data of the mysql database

datadir=D:\Tools\MySQL\mysql-5.7.16-winx64\data

# Allow the maximum number of connections

max_connections=200

# 8-bit encoded Latin1 character set

character-set-server=utf8

# The default storage engine that will be used when creating a new table

default-storage-engine=INNODB

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

This is the execution in the query

select @@GLOBAL.sql_mode;

Give

Different in the mysql version, the effect is different

If other versions such as 8.0 are useless, put sql_mode = strict_trans_tables, no_zero_in_date, no_zero_date, error_for_division_by_zero, no_AUTO_CREATE_USER, NO_ENGINE_SUBSTITEN, NO_ENGINE_SUBSTITTION, NO_ENGINE_SUBSTITTION, NO_ENGINE_SUBSTITTION, NO_ENGINE_SUBSTITION

If you can't do it, you only keep strict_trans_tables, no_engine_substitution and try again

Finally, restart the MySQL service

 

If there is a mistake, welcome to correct

Intelligent Recommendation

Mysql execute statement error this is incompatible with sql_mode=only_full_group_by

Error output: [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘information_schema.PROFILING.SEQ’ which is not functionally depende...

Solve mysql report this is incompatible with sql_mode=only_full_group_by error

Baidu found most of the two solutions, generally recommend the following one, I use it and solve the problem. add the following line at the end of mysql my.ini file...

mysql error: this is incompatible with sql_mode=only_full_group_by solution

1. Problem description: Use mysql 5.7.21 to execute the following statement: select u.login_name loginName,u.user_name userName,s.student_user_id userId, s.student_code studentCode,tc.schedule_class_n...

MySQL- this is incompatible with sql_mode=only_full_group_by error solution

For record, my local computer mysql version is 8.0.19, which is almost a relatively new version. Query database version statement: select VERSION() The following error will appear when using the GROUP...

MySQL Error --This IS INCOMPATIBLE with SQL_MODE = ONLY_FULL_GROUP_BY Perfect Solution

Project scene: Sometimes, I encountered database duplicate data, you need to group data and take it out to show it, then you need to use the Group by statement. However, if mysql is a high version, wh...

More Recommendation

[Mysql use error] this is incompatible with sql_mode = only_full_group_by

Some errors encountered when using MySQL 1. Err1055, this problem occurs often when performing a SQL statement, there will be this problem in the last line. Solution: In the /etc/my.cnf (linux) file, ...

MySQL-this is incompatible with sql_mode = only_full_group_by error solution

Execute SQL reported this question: this is incompatible with sql_mode=only_full_group_by Reason for problems: The result of the output is called Target List, which is the field followed by SELECT, as...

Solve and analyze mysql error: this is incompatible with sql_mode = only_full_group_by

Solve and analyze mysql error: this is incompatible with sql_mode = only_full_group_by When developing a timing task, I forgot to change the configuration (think of it yourself), causing a waste of ti...

Mysql Query "this is incompatible with sql_mode = only_full_group_by" error

problem When deploying a server-deployed server, the original SQL statement has appeared "this is incompatible with sql_mode = only_full_group_by" error. reason After mysql5.7.5, the default...

MySQL appears This Is IncomPatible With SQL_Mode = only_Full_group_BY error solution

This is the error screenshot Cause: MySQL version problem MySQL 5.7.5 above versions have achieved detection of functional dependence. If you enable the only_full_group_by SQL mode (default), mysql wi...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top