Laravel Auth Migrate Error

7 easy steps to resolve the SQLSTATE Query Exception error that is returned after running Laravel Auth Migrations.

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`))

1071 Specified key was too long; max key length is 767 bytes

Steps to reproduce the error

1.From the command line, you entered: php artisan make:auth which returned Authentication scaffolding generated successfully

2. Next step, run your migrations php artisan migrate

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`))
at vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {

How to Fix in 7 Steps

-> 1) From your database, review what tables exist.
MySQL Database

-> 2) Click on the migrations table. If the user migration was successful, you will see it here.
MySQL Database

-> 3) If your migrations table is empty drop the users table.

-> 4) Open the file AppServiceProvider.php located in the app/Providers directory.

-> 5) From within the boot function, set a default string length.
public function boot()
{
Schema::defaultStringLength(191);
}

-> 6) Also add

use Illuminate\Support\Facades\Schema;

-> below the line

use Illuminate\Support\ServiceProvider;

-> 7) Run your migration again.
php artisan migrate
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated: 2014_10_12_100000_create_password_resets_table

Your Laravel Auth scaffolding should now look and function as you would expect, without error.