今天安装laravel-admin的时候遇到了个SQL错误,大概就是下面这样:
SQLSTATE[42000]: 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`))
然后吧,我就慌了,我个萌新也不知道肿么办啊,好在官方的issue给出了解决办法,大概就是这样式的。 在app\Providers\AppServiceProvider.php添加默认值 修改前:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
}
修改成下面这样
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema; //后加的
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
Schema::defaultStringLength(191); //后加的
}
}
然后就可以了?
结果还是报错,正当我暴跳如雷的时候,突然看见了错误的原因,好嘛,原来是数据表已存在啊,直接去数据库把所有数据表都删掉。 完美解决~
如无特殊说明《关于laravel-admin安装时的错误》为博主MoLeft原创,转载请注明原文链接为:https://moleft.cn/post-161.html
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有