laravel migrate 报错:SQLSTATE[42000]: Syntax error or access violation

报错信息

 SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` a
  dd unique `users_email_unique`(`email`))

解决:

	// app\Providers\AppServiceProvider.php
	use Illuminate\Support\Facades\Schema;
	
	public function boot()
    {
        Schema::defaultStringLength(191);
    }

网上其它方法:

show variables like 'innodb_large_prefix';  

set global innodb_file_per_table=on;

set global innodb_large_prefix=on;

set global innodb_file_format_max='Barracuda';

set global innodb_file_format='Barracuda';

你可能感兴趣的:(laravel)