tags: Pits encountered mysql
After MySQL 5.7.5, ONLY_FULL_GROUP_BY is turned on by default, so some of the previous SQL cannot be executed normally. In fact, it is caused by our SQL irregularities, because after the group by, some data returned is uncertain, so it will This error occurred.
{"code":1,"data":{},"msg":"\n### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'a.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by\n### The error may exist in team/gk18software1dev/pcrsys/mapper/StudentMapper.java (best guess)\n### The error may involve team.gk18software1dev.pcrsys.mapper.StudentMapper.getListOnSelectByPcId-Inline\n### The error occurred while setting parameters\n### SQL: SELECT * from ( SELECT * from ( select student_choose_project.id,student_choose_project.stu_id, student_choose_project.pc_id,student_choose_project.p_id,student_choose_project.`status`, student.class_name,student.`name`,student.stu_number,student.telephone, student.station_name,student.wechat_num,student.email,student.remark from student_choose_project LEFT JOIN student on student_choose_project.stu_id=student.stu_id O
Turn off ONLY_FULL_GROUP_BY
Method 1:
select @@global.sql_mode;
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';
flush privileges;
Method Two:
Linux solution steps:
①, login into MySQL, linux login:mysql -u username -p , And then enter the password, enter SQL:show variables like '%sql_mode';
②. Edit the my.cnf file, the file address is generally:/etc/my.cnf,/etc/mysql/my.cnf,turn upsql-modePosition, removeONLY_FULL_GROUP_BY,thenRestart MySQL; Some my.cnf does not have sql-mode, you need to add:
sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,Note that if you want to add it under [mysqld], I just added it to other places, and it won't take effect after restarting.
③, restart the MySQL service after the modification is successful,service mysql restartAfter restarting, log in to mysql and enter SQL:show variables like '%sql_mode'; If there is no ONLY_FULL_GROUP_BY, it meanssuccessUp.
Remember once, when you migrate the service, connect to the new database, the database is also the backup of the previous, found an error: I started thinking that it was wrong when I imported i...
mysql ONLY_FULL_GROUP_BY error Error message: Solution: 1. error occurs again after the current environment modified configuration, service restart 2 Modify the start mysql my.ini configuration file t...
The following is the error message: The reason is: The default mode of the MySQL version 5.7 and later database is set to only_full_group_by mode, and when there are some duplicate rows in the execute...
Some time ago, when I deployed a program in a new environment, I encountered the MySql error only_full_group_by. I have encountered the same problem before. At that time, I did not summarize the exper...
Now that you know the problem, you can modify this configuration, find the MySQL configuration file, and query the sql_mode field in the /etc/my.cnf file on the linux system. I did not find this keywo...
Solve mysql only_full_group_by error Reference article: 1. Problem We sometimes encounter the following problems when performing a group of SQL statements: ERROR 1055 (42000): Expression #1 of SELECT ...
mysql5.7 + version is turned on by defaultonly_full_group_byMode,When you turn on this mode, the column must query conditions are grouped. The original group by statement will be reported this error. ...
On database 5.7, only_full_group_by mode will be enabled by default, but after enabling this mode, the original group by statement will report an error. Cause Analysis: For group by aggregation operat...
I wrote an sql when using mybits in the project: It was correct when tested on a machine, but it was wrong when it was put on the server: This matter caused an error because some versions of mysql5.7 ...
Solution: modify the mysql configuration file The local server can modify this Add under [mysqld] Then restart service mysql restart ...