Mysql ORDER BY clause is not in GROUP BY clause and contains nonaggregated column problem handling

Using the following command:

docker run -p 3306:3306 --name jiuhao-mysql 
-v F:/docker/mysql/datadir:/var/lib/mysql 
-e MYSQL_ROOT_PASSWORD=123456 -d  mysql

After starting mysql, executing a sql report the following error:

Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

Therefore, it is necessary to reconfigure the configuration of mysql to avoid it.

Start mysql with the following command, specifying the directory for the custom configuration:

docker run -p 3306:3306 --name jiuhao-mysql 
-v F:/docker/mysql/datadir:/var/lib/mysql 
-v F:/docker/mysql/conf:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=123456 -d  mysql

Where -v F:/docker/mysql/conf:/etc/mysql/conf.d is the key, maps a directory of the host to the conf.d directory in the container, and mysql in the container will load all the configurations under this directory .

can use

winpty docker exec -it jiuhao-mysql bash

Check the directory under /etc/mysql.

Next, create a mysql configuration file in the host's F:/docker/mysql/conf directory with a custom name. Here, my.cnf is still used as the file name. The configuration content is as follows:

[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

sql_mode can be modified according to your own needs.

Finally restart the container:

docker restart jiuhao-mysql

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324454313&siteId=291194637