MYSQL: how to fix error #1364 – Field ‘name’ doesn’t have a default value


Field name doesnt have a default value

Step 1: check sql_mode

select @@GLOBAL.sql_mode

mysql sql mode

You see STRICT_TRANS_TABLES in that value.

Step 2: use as root account then use this command:

set GLOBAL sql_mode = REPLACE( @@GLOBAL.sql_mode , 'STRICT_TRANS_TABLES,','')

Done, however, you should do more 2 steps (3 and 4) to fix this error on next reboot

Step 3: find your my.cnf

[root@tutorialspots ~]# cd /
[root@tutorialspots /]# find -name my.cnf
./etc/my.cnf

Step 4: add a line to my.cnf

sql_mode=ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

By using this command line:

echo sql_mode=ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION >>/etc/my.cnf

Leave a Reply