mysql 5.7如何修改 sql_mode

2016-08-12 14:02:00
hainuo
原創 2141
摘要:mysql 5.7 如何修改 sql_mode
#起源因上一篇文章[only_full_group_by是什麽鬼](https://blog.hainuo.info/blog/221.html) 修改 `mysql` 的 `sql_mode` 齣錯,本以爲在 `my.cnf` 中加入瞭 `sql_mode=''`就可以瞭卻髮現問題仍然存在#排查剛纔説瞭 `my.cnf` 中定義瞭 `sql_mode=''` 那麽怎麽查看生效沒生效呢。簡單 登陸終端或者進入`phpmyadmin`,這裡以終端演示```shell$ mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.13-log MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MySQL [(none)]> select @@sql_mode;+-------------------------------------------------------------------------------------------------------------------------------------------+| @@sql_mode |+-------------------------------------------------------------------------------------------------------------------------------------------+| 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 |+-------------------------------------------------------------------------------------------------------------------------------------------+1 row in set (0.00 sec)MySQL [(none)]> quit```#修複經過查看源碼 尤其是 `mysql.server` 的源碼髮現這裡有些問題,就是牠裡麵提到瞭一箇叫做`my-default.cnf` 的文件,然後將裡麵的 `sql_mode` 註釋掉 (在其前麵加入'#'字符)ps:`my-default.cnf` 位置跟 `mysql.server` 相衕爲 `mysql` 安裝目録的 `suppor-files` 目録
發錶評論
零 減 玖 =
評論通過審核後顯示。