MySQL之Field‘***’doesn’t have a default value錯誤解決辦法

首先排查一下數據庫中對應的字段是否是設置爲不能爲空,以至數據插入不進去。個人就是這個緣由解決的。sql

下面,整理一下網上的相同問題的其餘解決辦法,方便出現問題的同窗參考:數據庫

一、打開my.ini,查找this

sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"spa

修改成.net

sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"rest

而後重啓MYSQLorm

二、MySQL 5 uses a strict mode which needs to be disabled.htm

In Windows, Goto Start-->Programs-->MySQL->MySQL Instance Config Wizard. Follow through the Reconfigure Instance option-->Detailed Configuration-->Continue Next a few screens. At the bottom under Enable TCP/IP option there is 'Enable Strict Mode'. Deslect this option (no tick). Save changes and MySQL will restart.it

三、看看你的數據庫定義的時候是否是把主鍵生成方式設置爲int的,可是沒有設置爲自增的!!或者數據定義的時候設置一個默認值就能夠了。io

ps:

http://www.jb51.net/article/63554.htm

相關文章
相關標籤/搜索