Tag Archives: error

Dealing with databases in Laravel vol 2 – error SQLSTATE[42000]

Error: [Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table users add unique users_email_unique(email)) [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes Solution:
  • In your Laravel folder go to app - Providers - AppServiceProvider.php
  • Add use Illuminate\Support\Facades\Schema; after use Illuminate\Support\ServiceProvider; If you don't do it you'll get next error: [Symfony\Component\Debug\Exception\FatalErrorException] Class 'App\Providers\Schema' not found
  • Inside boot function add next line: Schema::defaultStringLength(191);
Now your AppServiceProvider.php file should look like this:





Find solution from laravel-news.com.