Mac 的mysql5.7没有配置文件,如何解决only_full_group_by 问题

图片描述

数据库版本是5.7.19,在写语句的时候,只要涉及ORDER BY,就会报错,

ERROR 1055 (42000): Expression #7 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'postscan.verifyDelayLog.auditor' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

这个时候,百度发现,是因为这个版本的mysql 数据库默认开启了 sql_mode 字段的only_full_group_by 属性。这个属性是在你写语句时,当你 ORDER BY 的字段不在select 的字段当中,都会报错。

sql_mode 属性是在mysql数据库,event表中,
图片描述
点进去,可以看到默认属性是

ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

解决这个问题,就需要修改这个字段的属性。

方法一
在navicat 里面直接针对event表进行修改

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 ';

这样就能去掉only_full_group_by 字段。但弊端是这个方法是针对session的,也就是说每次连接mysql 前,都需要set一次。

方法二
修改配置mysql的文件
mac在安装这个版本的mysql的时候,我没有发现mysql 的配置文件。不管是
/etc 下还是 mysql 的support-files 下都没有

图片描述

这个时候,可以自己在etc目录下创建一个

关闭mysql

sudo vim /etc/my.cnf

然后往文件里写这个配置就ok。

# Example MySQL config file for medium systems.  #  # This is for a system with little memory (32M - 64M) where MySQL plays  # an important part, or systems up to 128M where MySQL is used together with  # other programs (such as a web server)  #  # MySQL programs look for option files in a set of  # locations which depend on the deployment platform.  # You can copy this option file to one of those  # locations. For information about these locations, see:  # http://dev.mysql.com/doc/mysql/en/option-files.html  #  # In this file, you can use all long options that a program supports.  # If you want to know which options a program supports, run the program  # with the "--help" option.  # The following options will be passed to all MySQL clients  [client]default-character-set=utf8#password   = your_password  port        = 3306  socket      = /tmp/mysql.sock   # Here follows entries for some specific programs  # The MySQL server  [mysqld]character-set-server=utf8init_connect='SET NAMES utf8port        = 3306  socket      = /tmp/mysql.sock  skip-external-locking  key_buffer_size = 16M  max_allowed_packet = 1M  table_open_cache = 64  sort_buffer_size = 512K  net_buffer_length = 8K  read_buffer_size = 256K  read_rnd_buffer_size = 512K  myisam_sort_buffer_size = 8M  character-set-server=utf8sql_mode='NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT,ANSI_QUOTES'  init_connect='SET NAMES utf8' 
# Don't listen on a TCP/IP port at all. This can be a security enhancement,  
# if all processes that need to connect to mysqld run on the same host.  
# All interaction with mysqld must be made via Unix sockets or named pipes.  
# Note that using this option without enabling named pipes on Windows  
# (via the "enable-named-pipe" option) will render mysqld useless!  
#   
#skip-networking  # Replication Master Server (default)  # binary logging is required for replication  log-bin=mysql-bin  # binary logging format - mixed recommended  binlog_format=mixed  # required unique id between 1 and 2^32 - 1  # defaults to 1 if master-host is not set  # but will not function as a master if omitted  server-id   = 1  # Replication Slave (comment out master section to use this)  #  # To configure this host as a replication slave, you can choose between  # two methods :  #  # 1) Use the CHANGE MASTER TO command (fully described in our manual) -  #    the syntax is:  #  #    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,  #    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;  #  #    where you replace <host>, <user>, <password> by quoted strings and  #    <port> by the master's port number (3306 by default).  #  #    Example:  #  #    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,  #    MASTER_USER='joe', MASTER_PASSWORD='secret';  #  # OR  #  # 2) Set the variables below. However, in case you choose this method, then  #    start replication for the first time (even unsuccessfully, for example  #    if you mistyped the password in master-password and the slave fails to  #    connect), the slave will create a master.info file, and any later  #    change in this file to the variables' values below will be ignored and  #    overridden by the content of the master.info file, unless you shutdown  #    the slave server, delete master.info and restart the slaver server.  #    For that reason, you may want to leave the lines below untouched  #    (commented) and instead use CHANGE MASTER TO (see above)  #  # required unique id between 2 and 2^32 - 1  # (and different from the master)  # defaults to 2 if master-host is set  # but will not function as a slave if omitted  #server-id       = 2  #  # The replication master for this slave - required  #master-host     =   <hostname>  #  # The username the slave will use for authentication when connecting  # to the master - required  #master-user     =   <username>  #  # The password the slave will authenticate with when connecting to  # the master - required  #master-password =   <password>  #  # The port the master is listening on.  # optional - defaults to 3306  #master-port     =  <port>  #  # binary logging - not required for slaves, but recommended  #log-bin=mysql-bin  # Uncomment the following if you are using InnoDB tables  #innodb_data_home_dir = /usr/local/mysql/data  #innodb_data_file_path = ibdata1:10M:autoextend  #innodb_log_group_home_dir = /usr/local/mysql/data  # You can set .._buffer_pool_size up to 50 - 80 %  # of RAM but beware of setting memory usage too high  #innodb_buffer_pool_size = 16M  #innodb_additional_mem_pool_size = 2M  # Set .._log_file_size to 25 % of buffer pool size  #innodb_log_file_size = 5M  #innodb_log_buffer_size = 8M  #innodb_flush_log_at_trx_commit = 1  #innodb_lock_wait_timeout = 50  [mysqldump]  quick  max_allowed_packet = 16M  [mysql]  no-auto-rehash  # Remove the next comment character if you are not familiar with SQL  #safe-updates  default-character-set=utf8   [myisamchk]  key_buffer_size = 20M  sort_buffer_size = 20M  read_buffer = 2M  write_buffer = 2M  [mysqlhotcopy]  interactive-timeout

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/279945.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Spring MVC 入门(一)

什么是 Spring MVC 学习某一样东西之前&#xff0c;我们一定要大致知道这个东西是什么&#xff0c;能干什么&#xff0c;为什么要用它。 Spring MVC 是一个开源平台&#xff0c;一个基于 Spring 的 MVC 框架&#xff0c;它支持基于 Java 开发 Web 应用程序。MVC 架构很利于开发…

开源网关 Apache APISIX 认证鉴权精细化实战讲解

关注公众号并添加到“星标⭐”&#xff0c;防止错过消息后台回复【资料包】获取学习资料GitOps 新手入门到专家进阶实战详细教程作者钱勇&#xff0c;API7.ai 开发工程师&#xff0c;Apache APISIX Committer在当下云原生越发成熟的环境下&#xff0c;API 网关最核心的功能可以…

python应用POP3、IMAP、SMTP 协议,获取邮箱验证码

&#xff30;&#xff2f;&#xff30;&#xff13;和&#xff29;&#xff2d;&#xff21;&#xff30;是邮件相关的协议&#xff0c;&#xff29;&#xff2d;&#xff21;&#xff30;是比&#xff30;&#xff2f;&#xff30;&#xff13;更高级一点的协议&#xff0c;实…

固件中启用的虚拟化否_哪些固件或硬件机制可启用强制关机?

固件中启用的虚拟化否At one time or another, all of us have had to force our computers to shut down by pushing and holding the power button down until they powered off. Is this mechanism hardware-based, firmware-based, or both? Today’s SuperUser Q&A p…

简述闭包

闭包 这是我对闭包的一点小理解.有问题请直接指出,在此先谢过! 闭包的含义 封闭隔离的空间,在javascript中,只有函数能够符合这种特性; 为什么要用闭包呢? 因为在引用外部js文件(如jquery,各种框架)时防止变量重名造成的问题,同时也使代码更具隐私性; 获取闭包中数据的方法: …

Confluence 6 配置服务器基础地址备注

使用不同 URL。如果你配置了不同的基础 URL 地址或者你站点的访问者使用了不同的 URL 地址来访问你的 Confluence 地址&#xff0c;你有很大概率可能会受到错误信息。修改上下文地址。如果你修改了基础 URL 地址的上下文地址&#xff0c;你同时也需要修改下面的配置&#xff1a…

2019第10周知识总结

react 事件绑定 函数写法 文档总结 https://react.docschina.org/docs/handling-events.html 1 通过 constroucor绑定 class Toggle extends React.Component {constructor(props) {super(props);this.state {isToggleOn: true};// This binding is necessary to make this wo…

.NET 云原生架构师训练营(基于 OP Storming 和 Actor 的大型分布式架构二)--学习笔记...

▲ 点击上方“DotNet NB”关注公众号回复“1”获取开发者路线图学习分享 丨作者 / 郑 子 铭 这是DotNet NB 公众号的第202篇原创文章目录为什么我们用 OrleansDapr VS OrleansActor 模型Orleans 的核心概念结合 OP Storming 的实践结合 OP Storming 的实践业务模型设计模型代…

PHP 多维数组转json对象

PHP 多维数组转json对象 php 数组转json对象&#xff0c;可能大家都知道要用json_encode,但是转换出来的格式多有不同&#xff0c;此处做个小小的记录&#xff01; 1. 一维数组转json对象 <?php $arr_1 [one, two, three]; var_dump(json_encode($arr_1)); $arr_2 [0 >…

微软文本检索_如何在Microsoft Word中引用其他文档中的文本

微软文本检索You probably have some text that you type often in your Word documents, such as addresses. Instead of retyping this text every time you need it, you can put this common text into one Word document and reference it in other documents–it’ll eve…

Hadoop-Flume-类比吸尘器图解

2019独角兽企业重金招聘Python工程师标准>>> 这是我自己理解Hadoop-Flume的方式 转载于:https://my.oschina.net/u/3697442/blog/1560613

BZOJ4327:[JSOI2012]玄武密码(SAM)

Description 在美丽的玄武湖畔&#xff0c;鸡鸣寺边&#xff0c;鸡笼山前&#xff0c;有一块富饶而秀美的土地&#xff0c;人们唤作进香河。相传一日&#xff0c;一缕紫气从天而至&#xff0c;只一瞬间便消失在了进香河中。老人们说&#xff0c;这是玄武神灵将天书藏匿在此。 很…

ChatGPT 之后,再玩玩 Stable-Diffusion

前些天体验的 ChatGPT 主要用来进行文本方面的处理&#xff0c;那么图片生成有没有这样的 AI 工具 呢&#xff1f;答案是肯定的。例如&#xff1a;和菜头公众号的题图和文章中的插图大多都是使用 Stable-Diffusion 的 AI 图形生成工具创作的。顺着 Stable-Diffusion 搜索了下相…

渗透测试入门DVWA 教程1:环境搭建

首先欢迎新萌入坑。哈哈。你可能抱着好奇心或者疑问。DVWA 是个啥&#xff1f; DVWA是一款渗透测试的演练系统&#xff0c;在圈子里是很出名的。如果你需要入门&#xff0c;并且找不到合适的靶机&#xff0c;那我就推荐你用DVWA。 我们通常将演练系统称为靶机&#xff0c;下面请…

指派问题(匈牙利算法)

问题描述&#xff1a; 在生活中经常遇到这样的问题&#xff0c;某单位需完成n项任务&#xff0c;恰好有n个人可承担这些任务。由于每人的专长不同&#xff0c;各人完成任务不同(或所费时间)&#xff0c;效率也不同。于是产生应指派哪个人去完成哪项任务&#xff0c;使完成n项任…

移动硬盘改台式机硬盘_如何在台式机或移动设备上离线使用Google云端硬盘

移动硬盘改台式机硬盘If there’s any drawback to using cloud-based services for all your productivity and organization needs, it’s that if you can’t get an Internet connection, you’re basically out of luck. 如果使用基于云的服务来满足您的所有生产力和组织需…

你可能不知道的容器镜像安全实践

大家好&#xff0c;我是Edison。最近在公司搭建CI流水线&#xff0c;涉及到容器镜像安全的话题&#xff0c;形成了一个笔记&#xff0c;分享与你&#xff0c;也希望我们都能够提高对安全的重视。时代背景近年来应用程序逐步广泛运行在容器内&#xff0c;容器的采用率也是逐年上…

从零基础到拿到网易Java实习offer,谈谈我的学习经验

微信公众号【程序员江湖】作者黄小斜&#xff0c;斜杠青年&#xff0c;某985硕士&#xff0c;阿里研发工程师&#xff0c;于2018 年秋招拿到 BAT 头条、网易、滴滴等 8 个大厂 offer个人擅长领域 &#xff1a;自学编程、技术校园招聘、软件工程考研&#xff08;关注公众号后回复…

【Win 10 应用开发】UI Composition 札记(二):基本构件

在上一篇中&#xff0c;老周用一个示例&#xff0c;演示了框架视图的创建过程&#xff0c;在本篇中&#xff0c;老周将给大伙伴们说一下 Composition 构建 UI 的一些“零件”。 UI Composition 有一个核心类——对&#xff0c;就是 Compositor 类&#xff0c;它是总生产车间&am…

禁用内置键盘_如何禁用Windows 10的所有内置广告

禁用内置键盘Windows 10 has a lot of built-in advertising. This isn’t just about the free upgrade offer: Even if you purchase a new PC that comes with a Windows 10 license or spend $200 for a copy of Windows 10 Professional, you’ll see ads in your operati…