Loading...

MySQL:ERROR_1067

Temperature: 0 °C

Mark ChangMark Chang
author_tools

最近安裝了Ubuntu Server 18.04系統。
接著安裝了MySQL 5.7.21的版本。
在時間的預設值上發生了ERROR 1067 的錯誤警告。
原因是因為MySQL 5.7.21的版本默認的預設值是不允許時間欄位為0000-00-00 00:00:00。
如下:

mysql> show variables like '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

上頭顯示了NO_ZERO_IN_DATE,NO_ZERO_DATE的部分就是時間欄位預設不能為0。
解決方式,需要修改全局變量sql_mode,去掉NO_ZERO_IN_DATE,NO_ZERO_DATE。
如下:
mysql> set global sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

但是上列方式只適用於當前的生效,意思就是說若是重新啟動Mysql服務就會失效。
若要永久生效則必須在Mysql的安裝目錄底下my.cnf裡新增以下參數
 [mysqld]sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

之後重啟Mysql。

以上紀錄



 

https://innstory.com/story-MySQL:ERROR1067-2640
Mysql

Prev
 Linux底下查看Mysql版本

Next
分享_人事動盪!近400天GoogleCloud旅程告終台灣區總經理邵光華低調卸任|數位時代 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

  • guest

    訪客 2021-02-24 11:14:48 1

    技術文必須給讚
    • guest

      chung 2021-06-14 22:18:58 0

      TO:訪客
      回台灣了?

Recommended reading

Author's other related stories

使用手機將網址分享到 Line時,如何強制使用預設(外部)瀏覽器開啟?

使用手機將網址分享到 Lin...

如標題,當厭惡了每次在line上面分享demo網址給客戶時點選網址就會使用line的瀏覽器開啟。 還...

mysql 查詢數據資料是否有重複

mysql 查詢數據資料是否...

pexelsphoto5 有沒有試過資料庫裡上萬筆資料卻不知道是不是有重複的數據? 這時你一定要試試...

如何緩存靜態資源使用HTTP緩存

如何緩存靜態資源使用HTTP...

配置服務器以返回CacheControlHTTP響應標頭: CacheControl: maxage...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format