0

我正在尝试安装 laravel voyager 但收到此错误。

SQLSTATE[42000]:语法错误或访问冲突:1071 指定的键太长;最大密钥长度为 1000 字节(SQL:alter table users add unique users_email_unique( email))

这是我的 \app\Providers\AppServiceProvider.php

public function boot()
{
    Schema::defaultStringLength(191);
}

这是我的 config\database.php

'charset' => 'utf8',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',

我的数据库有颜色utf8mb4_unicode_ci

4

2 回答 2

0

你可以增加那个

SET @@global.innodb_large_prefix = 1;

例如


mysql> set global innodb_large_prefix = ON;
Query OK, 0 rows affected (0.00 sec)

于 2020-11-17T09:57:10.983 回答
-1

这里描述了一个类似的错误。

https://laravel-news.com/laravel-5-4-key-too-long-error

这里也有信息

Laravel 迁移错误:语法错误或访问冲突:1071 指定的键太长;最大密钥长度为 767 字节 成功编程 = )

于 2020-11-17T09:54:37.137 回答