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.pswp.cn/news/279945.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/279945.shtml
英文地址,請注明出處:http://en.pswp.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…