Laravel mysql migrate error Laravel mysql migrate error php php

Laravel mysql migrate error


I finally found the solutions a days ago and I remembered this post.In the config/database.php file in mysql tag, the sql modes should be added in order to skip this error. https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sql-mode-full

My MySQL array ended up like this:

    'mysql' => [        'driver' => 'mysql',        'host' => env('DB_HOST', '127.0.0.1'),        'port' => env('DB_PORT', '3306'),        'database' => env('DB_DATABASE', 'forge'),        'username' => env('DB_USERNAME', 'forge'),        'password' => env('DB_PASSWORD', ''),        'unix_socket' => env('DB_SOCKET', ''),        'charset' => 'utf8mb4',        'collation' => 'utf8mb4_unicode_ci',        'prefix' => '',        'strict' => true,        'engine' => null,        'modes'  => [            'ONLY_FULL_GROUP_BY',            'STRICT_TRANS_TABLES',            'NO_ZERO_IN_DATE',            'NO_ZERO_DATE',            'ERROR_FOR_DIVISION_BY_ZERO',            'NO_ENGINE_SUBSTITUTION',        ],    ],


In file:

config/database.php

'mysql' =[    ...    'strict' => false]

Also disable sql_mode

via SQL:

SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';

via my.cnf inside heading [mysqld]

sql_mode=NO_ENGINE_SUBSTITUTION

Test the changes:

SHOW VARIABLES LIKE 'sql_mode';


Effectively you must add this code at the end of each of the connections you have with the mysql driver

'modes' => [             'ONLY_FULL_GROUP_BY',             'STRICT_TRANS_TABLES',             'NO_ZERO_IN_DATE',             'NO_ZERO_DATE',             'ERROR_FOR_DIVISION_BY_ZERO',             'NO_ENGINE_SUBSTITUTION',         ],