Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.5 with MySQL 8.0.11: 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'

I've just installed MySQL 8.0.11, transfered my app's database into it and changed the laravel database settings to use the new one. Now everytime I try to login I get the following error:

ERROR 1231 (42000):
Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'

I tried to set NO_AUTO_CREATE_USER manually:

set global sql_mode="..., NO_AUTO_CREATE_USER, ...";

But I get the same error. How could I solve the problem and run laravel 5.5 with MySQL 8.0.11?

like image 202
manifestor Avatar asked Apr 27 '18 18:04

manifestor


3 Answers

your laravel connexion (config / database.php) should be such that:

'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', 'localhost'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8',
        'collation' => 'utf8_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',
            ],
    ],
like image 59
eValdezate Avatar answered Nov 19 '22 10:11

eValdezate


Add the following on each of your MySQL connections:

'modes' => [
     'ONLY_FULL_GROUP_BY',
     'STRICT_TRANS_TABLES',
     'NO_ZERO_IN_DATE',
     'NO_ZERO_DATE',
     'ERROR_FOR_DIVISION_BY_ZERO',
     'NO_ENGINE_SUBSTITUTION',
],
like image 22
nasirkhan Avatar answered Nov 19 '22 11:11

nasirkhan


The next release of Laravel 5.5 will add support for MySQL 8.0: https://github.com/laravel/framework/pull/24038

UPDATE: Laravel 5.5.41 has been released.

like image 39
Jonas Staudenmeir Avatar answered Nov 19 '22 11:11

Jonas Staudenmeir