Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (S

安装laravel-admin   执行:php artisan admin:install报错如下:

In Connection.php line 664:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (S
  QL: alter table `users` add unique `users_email_unique`(`email`))
In PDOStatement.php line 107:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
In PDOStatement.php line 105:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes

[PDOException] 
SQLSTATE [42000]:语法错误或访问冲突:1071指定密钥太长; 最大密钥长度为1000字节

要解决此问题,您只需编辑 AppServiceProvider.php文件并在 boot方法内设置默认字符串长度:

use Illuminate\Support\Facades\Schema; 
public function boot()
    {
        Schema::defaultStringLength(191);
        
    }

在执行php artisan admin:install   删除之前创建的表,就正常了

猜你喜欢

转载自blog.csdn.net/cmj8043719242/article/details/105380511