我正在使用Laravel,当我尝试运行 php artisan make:migrate
时,它显示以下错误:
Illuminate \ Database \ QueryException:SQLSTATE [42000]:语法错误或访问冲突:1071指定密钥太长;最大密钥长度为767字节(SQL:alter table users添加唯一users_email_unique(email))/Users/soksan/Desktop/TestLaravel/multiUsers/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
异常跟踪:
1 PDOException ::(“SQLSTATE [42000]:语法错误或访问冲突:1071指定密钥太长;最大密钥长度为767字节”)/ Users / soksan / Desktop / TestLaravel / multiUsers / vendor / laravel / framework / src / Illuminate / Database / Connection.php:458 2 PDOStatement :: execute()/Users/soksan/Desktop/TestLaravel/multiUsers/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
请使用参数 -v
查看更多详细信息 .
1 回答
进入
App\Providers\AppServiceProvider
类并将引导方法更改为如下所示