mysql8 安装无my.ini配置文件和执行groupBy报错修改sql_mode不生效的解决方案

Posted 大孟子

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql8 安装无my.ini配置文件和执行groupBy报错修改sql_mode不生效的解决方案相关的知识,希望对你有一定的参考价值。

安装很多次mysql,linux,windows版本的都有遇到的问题,总是不总结,结果就是走很多弯路,所以此次记录一下。

1.首先安装完mysql8.0.21 后,发现无my.ini,解决办法

1)默认安装到c盘会自动隐藏,记得打开隐藏文件找到他

2)找不到的情况下,在mysql的安装目录下新建my.ini文件(注意:刚新建完是没有小齿轮的,需要以下配置信息添加进去)

 

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It‘s a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_bin
init_connect=‘SET NAMES utf8mb4‘
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = E:mysql-8.0.21-winx64
datadir = E:mysql-8.0.21-winx64data
port = 3306
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 16M
read_rnd_buffer_size = 16M 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

 

 

 

2.报错[Err] 1055 - 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

1网上的解决方案都是修改sql_mode 但是因为我的my.ini没有这个文件,怎么改都不生效,如果您也遇到同样的问题记得先把第一步操作了,重新启动mysq

2)在添加my.ini文件的时候就把sql_mode参数添加进去

3)该方法若mysql重启则失效

mysql中执行 show variables like ‘%sql_mode‘;

set @@GLOBAL.sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION‘;

以上是关于mysql8 安装无my.ini配置文件和执行groupBy报错修改sql_mode不生效的解决方案的主要内容,如果未能解决你的问题,请参考以下文章

mysql8.0.20安装教程

Mysql8安装教程与配置(详细步骤)

Mysql8安装教程与配置(详细步骤)

安装mysql没有my.ini文件

mysql8安装教程

Win10下免安装版MySQL8.0.16的安装和配置