Mysql [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause

11057 ワード

select version();
# 5.7.17

通常のクエリエラー:[Err]1055-Expression#1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column
Trouble shootingプロシージャ(mysql 5.7プロファイルのパスに注意):
root@TESTDB:~# cd /
root@TESTDB:/# find -name my.ini
root@TESTDB:/# find -name my.cnf
./etc/alternatives/my.cnf
./etc/mysql/my.cnf
./var/lib/dpkg/alternatives/my.cnf
root@TESTDB:/# cat /etc/mysql/my.cnf
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
root@TESTDB:/# cat  /etc/mysql/conf.d/
cat: /etc/mysql/conf.d/: Is a directory
root@TESTDB:/# cd  /etc/mysql/conf.d/
root@TESTDB:/etc/mysql/conf.d# ll
total 12
drwxr-xr-x 2 root root 4096 May  8 19:29 ./
drwxr-xr-x 4 root root 4096 May  9 10:56 ../
-rw-r--r-- 1 root root  875 Nov 29 03:59 mysql.cnf
root@TESTDB:/etc/mysql/conf.d# cat mysql.cnf
# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

#
# The MySQL  Client configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysql]
root@TESTDB:/etc/mysql/conf.d# cd /etc/mysql/mysql.conf.d/
root@TESTDB:/etc/mysql/mysql.conf.d# ll
total 12
drwxr-xr-x 2 root root 4096 May  9 10:55 ./
drwxr-xr-x 4 root root 4096 May  9 10:56 ../
-rw-r--r-- 1 root root 1212 May  8 19:36 mysqld.cnf
root@TESTDB:/etc/mysql/mysql.conf.d# cat mysqld.cnf
# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

#
# The MySQL  Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysqld]
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
datadir     = /var/lib/mysql
log-error   = /var/log/mysql/error.log
lower_case_table_names=1
# By default we only accept connections from localhost
bind-address    = 0.0.0.0
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
############      
root@TESTDB:/etc/mysql/mysql.conf.d# vim mysqld.cnf
############      ,   :
############sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
root@TESTDB:/etc/mysql/mysql.conf.d# cat mysqld.cnf
# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

#
# The MySQL  Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysqld]
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
datadir     = /var/lib/mysql
log-error   = /var/log/mysql/error.log
lower_case_table_names=1
# By default we only accept connections from localhost
bind-address    = 0.0.0.0
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
###########  Mysql
root@TESTDB:/etc/mysql/mysql.conf.d# service mysql restart
 * Stopping MySQL Community Server 5.7.17
.....
 * MySQL Community Server 5.7.17 is stopped
 * Re-starting MySQL Community Server 5.7.17
..
 * MySQL Community Server 5.7.17 is started