PS D:\Centos\PHPstudyWWW\dcatAdmin> php artisan admin:install
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
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:\Centos\PHPstudyWWW\dcatAdmin\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 Doctrine\DBAL\Driver\PDO\Exception::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes")
D:\Centos\PHPstudyWWW\dcatAdmin\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDO\Exception.php:18
2 Doctrine\DBAL\Driver\PDO\Exception::new(Object(PDOException))
D:\Centos\PHPstudyWWW\dcatAdmin\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php:119
Please use the argument -v to see more details.
PS D:\Centos\PHPstudyWWW\dcatAdmin>
laravel报错 “ SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes”
原因:mysql版本较低
解决办法:app\Providers\AppServiceProvider.php
下修改 boot()
方法添加如下代码
Schema::defaultStringLength(191);
完整代码
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?