MySQL5.7 group by new feature, error 1055

 

Error phenomenon:

 

Error reason: The mode of only_full_group_by in mysql5.7 is enabled by default 

 

  •  

The project originally used mysql5.6 for development. After switching to 5.7, I suddenly found that some of the original SQL operations reported errors, the error code was 1055, and the error message was related to "only_full_group_by" in sql_mode. I read the reason on the Internet and said yes In mysql5.7, the only_full_group_by mode is enabled by default. 
There are roughly two solutions: 
one: use the any_value() function on the fields that do not require group by in the sql query statement. 
Of course, this is for projects that have developed many functions. It is not suitable, after all, the original sql should be modified again

Two: Modify the my.cnf (my.ini under windows) configuration file, delete the only_full_group_by item My 
project's mysql is installed on ubuntu, find this file and open it, there is no sql_mode configuration item in it, I want to delete it None have to be deleted. 
Of course, there are other ways to open the mysql command line and execute the command

select @@sql_mode
  • 1

In this way, you can find out the value of sql_mode, copy this value, and add configuration items in my.cnf (delete the option only_full_group_by from the queried value, and copy the others):

sql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
  • 1

Remember to turn on comments if the [mysqld] line is commented out. Then restart the mysql service

 

Reprinted: http://blog.csdn.net/u283056051/article/details/52463948

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326117894&siteId=291194637