Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

似乎 Laravel 数据库连接无法兼容 MySql 8.0? #1977

Closed
BI7PRK opened this issue Apr 26, 2018 · 2 comments
Closed

似乎 Laravel 数据库连接无法兼容 MySql 8.0? #1977

BI7PRK opened this issue Apr 26, 2018 · 2 comments

Comments

@BI7PRK
Copy link

BI7PRK commented Apr 26, 2018

  • Laravel Version: 5.6.17
  • PHP Version: 7.2
  • Laravel-admin: 1.5.*
  • MySql: 8.0.11

Description:

 Exception trace:
 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'")

Steps To Reproduce:

MySql 全局设置

sql-mode='STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION'

执行命令:

php artisan admin:install

MySql日志输出:

2018-04-26T07:24:48.534238Z	    9 Connect	root@localhost on lavavel using TCP/IP
2018-04-26T07:24:48.534555Z	    9 Query	use `lavavel`
2018-04-26T07:24:48.534890Z	    9 Prepare	set names 'utf8mb4' collate 'utf8mb4_unicode_ci'
2018-04-26T07:24:48.534974Z	    9 Execute	set names 'utf8mb4' collate 'utf8mb4_unicode_ci'
2018-04-26T07:24:48.535112Z	    9 Close stmt	
2018-04-26T07:24:48.535193Z	    9 Prepare	set session sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
2018-04-26T07:24:48.535262Z	    9 Execute	set session sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
2018-04-26T07:24:48.535473Z	    9 Close stmt

尝试改代码:

 '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',
	    'sql_mode' => 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION',  // 企图设定连接模式
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ]

问题依旧。有解决的办法吗?

@haodiao
Copy link

haodiao commented Apr 30, 2018

请参考:laravel/framework#23948

@z-song z-song closed this as completed May 7, 2018
@yoolom
Copy link

yoolom commented Jun 20, 2018

'strict' => true,改为'strict' => false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants