LaravelMySQLPHP

Mysql General Error 1364 Field Doesn’t Have Default Value

Hi All,

Since I’ve updated my homestead to 0.3.0 and mysql version is upgrade to 5.7.4. From that moment, my old projects has been started to throw problems which is Mysql General Error 1364 Field doesn’t have default value.

Even migrations was not working, there has to be a problem. After my first research I’ve found a solution for Php Laravel Projects there is a “strict” parameter for mysql connection, when I set it true migrations worked well.. But, in some cases, I let the mysql to set default value such as integer fields are sets to ‘0’ and varchar fields are empty strings etc.. I need to use default values as before..

Finally, I solved my problem it’s all about SQL Mode Strict

select @@sql_mode;

If the result includes STRICT_TRANS_TABLES parameters Mysql engine expect default parameters for field, otherwise you have to set that.

Open terminal at the below command or find your my.ini/my.cnf file

sudo nano /etc/mysql/my.cnf

Add at the below line after [mysqld]

sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

Try again..

Muharrem Tığdemir

Author

Muharrem Tığdemir

One thought on “Mysql General Error 1364 Field Doesn’t Have Default Value

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.