-->

[Laravel 5.6] How To Fix Sqlstate[42000]: Syntax Error Or Access Violation: 1071 Specified Key Was Too Long

Hello guys, in this time i will share about how to fix SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long.

Today, i learn laravel 5.6 version, and when i execute command 'php artisan migrate' i get error like this :

Illuminate\Database\QueryException  : 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`)

If you get same error with me, you can fix these error.

1. Open file AppServiceProviders.php, you can edit file in directory  app/Providers/

2. Write this code

use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}

3. Finish, your errors is fixed



Sumber https://rafibanget.blogspot.com/

Baca juga: