If you are using MySQL 8 or 5.7, on Laravel Forge, for example, use the command sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
. The options file /etc/mysql/conf.d/mysql.cnf
is not the .cnf
file we are using in this particular instance.
Then add the sql_mode options you need and wrap them in quotes under the [mysqld]
group. The sql_mode options needed to disable NO_ZERO_IN_DATE errors are:
sql_mode = "ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
Then, restart MySQL with sudo service mysql restart
and check your sql_mode if desired.
Note that NO_AUTO_CREATE_USER was removed in MySQL 8.0.11 so avoid using that option.
Solves MySQL Error Codes
- [ERR] 1067 – Invalid default value
- ERROR 1067 (42000): Invalid default value for
These errors are often seen in Laravel for created_at, updated_at, and deleted_at.
Leave a Reply