【发布时间】:2018-10-03 02:27:09
【问题描述】:
我正在使用 laravel 5.6.17 和 php 7.2;当我运行php artisan migrate 命令时,我收到以下错误。
有关详细信息,已在声明的数据库中创建了默认表“users”和“migrations”。
laravel 不支持 php 7.2 吗??
Image: laravel 5.6.17 php artisan migrate error
Migration table created successfully.
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
at D:\xampp\htdocs\laravel\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|
Exception trace:
1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes")
D:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
2 PDOStatement::execute()
D:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
Please use the argument -v to see more details.
【问题讨论】:
-
您的问题出在您的 SQL 中,而不是在 artisan 中,不在 PHP 中,也不在 Laravel 中。你试图索引一些东西,它不适合索引。发布您的迁移,不要将互联网上的随机代码作为解决方案,因为您得到的不是解决方案,它只会隐藏问题。
-
这不是重复的,因为提供的答案是废话且不正确。
标签: php laravel-5.6