• Skip to primary navigation
  • Skip to main content
  • Skip to footer
  • Home
  • Blog
  • Search

Kevin Dees

Full-Stack PHP Development

  • Twitter
  • Github
  • LinkedIn
You are here: Home / Fix / Disable MySQL Strict Mode and NO_ZERO_DATE Errors in Laravel Homestead

Disable MySQL Strict Mode and NO_ZERO_DATE Errors in Laravel Homestead

December 18, 2018 by Kevin Leave a Comment

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

  1. [ERR] 1067 – Invalid default value
  2. ERROR 1067 (42000): Invalid default value for

These errors are often seen in Laravel for created_at, updated_at, and deleted_at.

Filed Under: Fix, Laravel, Servers, SQL, Web

Reader Interactions

Leave a Reply Cancel 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.

Footer

Get Dare To Code

Get the latest on full-stack PHP development in your inbox with a bi-weekly lesson from Kevin Dees.

Copyright © 2021 · Kevin Dees · Log in