Solution for MySQL5.7 group by new feature error 1055

  • 2021-06-28 14:20:51
  • OfStack

The project was originally developed using mysql 5.6. After switching to 5.7, I suddenly found that some of the original sql runs had errors, error code 1055, error information and sql_"only_in modefull_group_by, "About, read the reason online, said only_in mysql5.7full_group_by This mode is turned on by default
There are roughly two solutions:

1: Use any_on fields that do not require group by in an sql query statementvalue() function

Of course, this is not appropriate for projects that have developed a lot of functionality, after all, you have to modify the original sql once

2: Modify the my.cnf (my.ini under windows) configuration file and delete only_full_group_by This one

The mysql of our project is installed on ubuntu. Find this file and open it. There is no sql_in it.mode configuration item, you can't delete it if you want to.

Of course, there is another way to open the mysql command line and execute the command


select @@sql_mode

This will identify sql_mode value, copy this value, add a configuration item to my.cnf (delete only_from the queried value)full_group_by option, all others copied in the past:


sql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

If [mysqld] is commented out, remember to open the comment.Then restart the mysql service

Note: Use commands


set sql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

This allows you to modify configuration items in one session that are not valid in other sessions.


Related articles: