date: 0629
問(wèn)題背景:
是 mysqldump 導(dǎo)出的備份嚎幸,恢復(fù)到新安裝的 MySQL 5.7.17 上,因?yàn)槟J(rèn)參數(shù)配置出現(xiàn)一些問(wèn)題:
1花沉,sql_mode=only_full_group_by問(wèn)題
2坟比,表名大小寫敏感問(wèn)題
1, 發(fā)現(xiàn) java 日志報(bào)錯(cuò):
java 報(bào)錯(cuò)
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #2 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'dangdi_v15.dd_noticetoplate.sortOrder' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
網(wǎng)查解決方法 :執(zhí)行SET GLOBAL sql_mode = ''; 把sql_mode 改成非only_full_group_by模式本姥。
驗(yàn)證是否生效 SELECT @@GLOBAL.sql_mode 或 SELECT @@sql_mode。
查看當(dāng)前默認(rèn)的 sql_mode:
mysql> select @@global.sql_mode\G
*************************** 1. row ***************************
@@global.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
修改 mysql 配置文件焦辅,修改 sql_mode:
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
重啟 mysql
也可先在線修改使得及時(shí)生效:
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';
老數(shù)據(jù)庫(kù)的 sql_mode:
STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
2,表名大小寫敏感問(wèn)題
由 java 的日志報(bào)錯(cuò)椿胯,發(fā)現(xiàn)新庫(kù)對(duì)表名大小寫敏感:
查看方法:
SELECT @@GLOBAL.lower_case_table_names
修改方法:
及時(shí)生效:
SET @@global.lower_case_table_names=1
長(zhǎng)久生效:
配置文件中添加:lower_case_table_names=1筷登,然后重啟 MySQL