I am trying to run migrations on my Laravel instance. They are just the default migrations (users and password resets) but when it tries to make the timestamps it throws this e
you should disable MySQL strict mode on Laravel.
MySQL has had a strict mode since 5.1, but in 5.7 it became the default.
In Laravel, you can fix this in code: edit your database.php
config file, and add a key of strict
with a value of false
.
for non-Laravel users:
if you're using a non-Laravel application,you won't have that option.Here's how to disable strict mode globally.find your MySQL configuration file my.cnf
or my.ini
the default MySQL configuration will live in /etc/mysql/my.cnf
open the file and find the [mysqld]
section.We're going to add a new key, sql_mode
On MySQL 5.7, the default values for this key out of the box are:
STRICT_TRANS_TABLES,ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
The strict mode comes from STRICT_TRANS_TABLES
. So, let's overwrite the sql_mode
to:
[mysqld]
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
That's it! Save the file, and restart MySQL.