Home > Database > Mysql Tutorial > body text

How to Fix MySQL Error #1055: \'Expression of SELECT list is not in GROUP BY clause\'?

Barbara Streisand
Release: 2024-11-23 15:30:11
Original
330 people have browsed it

How to Fix MySQL Error #1055:

#1055 - Expression of SELECT list is not in GROUP BY clause and contains nonaggregated column this is incompatible with sql_mode=only_full_group_by

In this programming issue, the user encounters the error message "#1055 - Expression of SELECT list is not in GROUP BY clause and contains nonaggregated column this is incompatible with sql_mode=only_full_group_by" while attempting to run a query in MySQL. To resolve this error, the user must modify the MySQL configuration file (mysql.cnf) to set the sql_mode parameter to STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION.

The user provides the following steps to successfully resolve the error:

  1. Edit the MySQL configuration file (/etc/mysql/conf.d/mysql.cnf) using a text editor like vim:
sudo vim /etc/mysql/conf.d/mysql.cnf
Copy after login
  1. Scroll to the bottom of the file and add the following lines:
[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Copy after login
  1. Save the file and exit the text editor.
  2. Restart the MySQL service:
sudo service mysql restart
Copy after login

After completing these steps, the user should be able to execute the original query without encountering the error.

The above is the detailed content of How to Fix MySQL Error #1055: \'Expression of SELECT list is not in GROUP BY clause\'?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template