<< cd ..

$ cat laravel-syntax-error-or-access-violation-1231-variable-sql-mode-cant-be-set-to-the-value-of-no-auto-create-user.md

# Laravel Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'

// · 1 min read · christopheredrian

Fixing a Laravel migration error caused by MySQL 8's deprecated NO_AUTO_CREATE_USER sql_mode.

Laravel error: Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'

I had an old Laravel project that needed update and when I did php artisan migrate I encountered this error

Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'

It seems to be an issue on my newly installed MySQL 8

The solution that worked for me is this one:

On database/config.php add the following on the mysql key

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

That's it! Hopefully someone was helped by this post