laravel-admin安装出现错误1071 Specified key was too long 造成这个问题的原因是数据库创建特殊字符过长问题

就是执行 php artisan admin:install 命令时候

估计大家在安装laravel-admin时候就是遇到两个问题

第一个:

Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))

说明是最大密钥长度为1000字节 由于密钥过长 造成这个问题的原因是:数据库创建特殊字符过长问题

这个时候 你的数据库已经生成了 两张表了 一张是 migrations 一张是users表

先说说解决这个问题方法

就是在app\Providers\AppServiceProvider.php的 boot方法中添加下代码

记得在上面引入对应的类 就可以了

use Illuminate\Support\Facades\Schema;

public function boot()

{

Schema::defaultStringLength(191); //add fixed sql

}

执行命令前 先删除数据库里面已存在的两张表 不然就会报错第二错误了

重新执行:php artisan admin:install

第二个:

Base table or view already exists: 1050 Table 'users' already exists (SQL: create table `users` (`id` bigint unsigned not null auto_increment primary key, `name` varchar(19 1) not null, `email` varchar(191) not null, `email_verified_at` timestamp null, `password` varchar(191) not null, `remember_token` varchar(100) null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

提示这个 就是说 你的users 表已经存在了

所以把已存在的数据表 去掉

重新的执行命令 php artisan admin:install 即可

出现下面即可安装成功了

猜你喜欢

转载自blog.csdn.net/YMB_jack/article/details/107003733