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…

.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

ChatGPT 之后,再玩玩 Stable-Diffusion

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

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

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

移动硬盘改台式机硬盘_如何在台式机或移动设备上离线使用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;容器的采用率也是逐年上…

【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…

震惊!顶着 39.5℃高烧 ,我和这哥俩都聊了些啥?

这是头哥侃码的第271篇原创上周三&#xff0c;我邀请了两位嘉宾进入直播间&#xff0c;即便自己顶着 39.5 度的高烧&#xff0c;还是强打精神与这哥俩聊了俩小时。相信关注我的朋友们都知道&#xff0c;我是头哥侃码的主理人&#xff0c;同时也是上海TGO上海分会董事会成员。赵…

在Windows Mobile模拟器(Emulator)建立网络连接

因为想使用Windows Mobile Emulator进行网络通信程序的测试&#xff0c;所以找方法配置Emulator的网络连接。在网上找了一些文章&#xff0c;很多都说需要安装Virtual PC 2007. 例如下面的文章Enable Network Connection Windows Mobile 6 Emulator 如果需要 Virtual PC 2007 可…

api游戏编程鼠标选择拖动_如何选择合适的游戏鼠标

api游戏编程鼠标选择拖动You don’t need a gaming mouse to play PC games—just about any mouse with two buttons and a wheel will play anything you want it to. But that’s no reason to deny yourself the wonderful variety of gaming mouse designs on the market.…

iOS - 上架的APP 生成二维码下载

1.首先打开苹果App Store商店进入到里面&#xff0c;找到需要打开链接地址的应用程序&#xff0c;例如&#xff1a;百度。2. 在App Store商店里面先点击一下应用程序图标&#xff0c;再按一下…分享按钮。 3. 接着选择分享APP&#xff0c;再点击拷贝链接地址&#xff0c;将应用…

Rsa2加密报错java.security.spec.InvalidKeySpecException的解决办法

最近在和支付宝支付做个对接&#xff0c;Java项目中用到了RSA2进行加解密&#xff0c;在加密过程中遇到了错误&#xff1a; java.security.spec.InvalidKeySpecException: java.security.InvalidKeyException: IOException : algid parse error, not a sequence 代码执行到这句…

浅析领域驱动设计

1.概要DDD&#xff08;Domain-driven design&#xff0c;模型驱动设计&#xff09;是一种软件设计的指导思想&#xff0c;而非固定的一套公式化开发模板&#xff08;这样就会导致网络上出现各种基于自己或业务上的理解而产出的DDD落地的实现&#xff0c;会让很想学习的开发者迷…