CHINA PHP CODER

CHINA PHP CODER

Who am I?

I am a china php coder.


What I write about


Recent Posts

laravel sql_mode错误NO_AUTO_CREATE_USER

  Laravel5.5+MySQL8配置好了后,操作数据库出现:

"SQLSTATE[42000]: Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER' (SQL: select count(*) as aggregate from `users` where `email` = 'admin@126.com')"

  laravel 连接 (config / database.php) mysql的sql_mode应该像如下:

'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',
            ],
    ],