[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
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
0 Response to "[Laravel 5.6] How to Fix SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long"
Post a Comment
1. Berikan Komentar yang Relevan
2. Tidak Mengandung SARA
3. Berkomentar yang Sopan