Problem statement
This error is reported because non-grouping fields are displayed when querying grouping. Example:
select id , user_name from user group by user_name;
The above statement queries the id and user_name fields. User_name is grouped, but id is not. At this time, mysql will report the above error.
solution
There are many methods mentioned in other blog posts, but I will write down the most practical ones here.
Find the my.ini file in the mysql installation directory. I don’t know if there is a mysql installation version for the win system.
I usually decompress the mysql version and then initialize the installation, so this my.ini file must be there.
The configuration file will be in the following format:
[mysqld]
配置...
[mysql]
配置...
[client]
配置...
[mysqld]
Add below sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
You can close it after adding. What it will only_full_group_by
look like after the addition is completed:
[mysqld]
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
其它配置....
[mysql]
配置...
[client]
配置...
easy to make mistakes
The adding position is wrong, please note it must be [mysqld]
at the bottom .
…I just copied it to [mysql]
the next page, but it didn’t work no matter how I restarted the mysql service. It took me 20 minutes to do this...