Laravel Syntax error or access violation: 1071 Specified key was too long; max key length is 767
Laravel
When trying to get the default Laravel Authentication up and running I ran into this error.
'Illuminate\Database\QueryException' with message '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`))'
I found this solution to work:
https://laravel-news.com/laravel-5-4-key-too-long-error
As outlined in the Migrations guide to fix this all you have to do is edit your AppServiceProvider.php
file and inside the boot
method set a default string length:
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
You will also need to add this:
use Illuminate\Support\Facades\Schema;