带有 MySQL 8.0.11 的 Laravel 5.5:“sql_mode”不能设置为“NO_AUTO_CREATE_USER”的值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50068663/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:41:07  来源:igfitidea点击:

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

mysqllaravellaravel-5.5

提问by manifestor

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:

我刚刚安装了 MySQL 8.0.11,将我的应用程序的数据库转移到其中并更改了 laravel 数据库设置以使用新的数据库设置。现在每次我尝试登录时都会出现以下错误:

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_USERmanually:

我尝试NO_AUTO_CREATE_USER手动设置:

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

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

但我得到了同样的错误。我如何解决问题并5.5使用 MySQL运行 laravel 8.0.11

采纳答案by Jonas Staudenmeir

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

Laravel 5.5 的下一个版本将添加对 MySQL 8.0 的支持:https: //github.com/laravel/framework/pull/24038

UPDATE: Laravel 5.5.41 has been released.

更新:Laravel 5.5.41 已经发布。

回答by eValdezate

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

你的 Laravel 连接(配置/database.php)应该是这样的:

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

回答by nasirkhan

Add the following on each of your MySQL connections:

在每个 MySQL 连接上添加以下内容:

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

回答by KAGG Design

MySQL 8.0 does not support NO_AUTO_CREATE_USER

MySQL 8.0 不支持 NO_AUTO_CREATE_USER

Documentation: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-11.html

文档:https: //dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-11.html

回答by Pemtium

Since MySQL 8.0 at this Moment(as today) does not support NO_AUTO_CREATE_USER you should find and replace in your backup: "NO_AUTO_CREATE_USER," by Space

由于此时的 MySQL 8.0(就像今天一样)不支持 NO_AUTO_CREATE_USER,您应该在备份中找到并替换:“NO_AUTO_CREATE_USER”,按 Space

this way Backup from 5.7 will restore ok in 8.0

这样从 5.7 备份将在 8.0 中恢复正常

回答by Kennedy Kairu Kariuki

I'm using MySQL 8.0.18 on Windows Wampserver and adding the below to database.php for Laravel

我在 Windows Wampserver 上使用 MySQL 8.0.18 并将以下内容添加到 database.php for Laravel

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