Syntax error or access violation: 1071 specified key was too long; max key length is 767 bytes

Laravel 5.4 has made a change to the default database character set and now utf8mb4 which includes support for storing emojis. This only affects new applications, and as long as you’re running MySQL V5.7.7 and later, you don’t need to do anything.
For users running MariaDB or older versions of MySQL, you may encounter this error when trying to run the migration:

[Illuminate \ Database \ QueryException] SQLSTATE[42000]: Syntax Error or Access Restriction: 1071 Specified key was too long; Max key length is 767 bytes (SQL: alter table users add uniqueusers_email_unique (email)
[PDOException]
SQLSTATE [42000] : syntax error or access conflict: 1071 specified key is too long; The maximum key length is 767 bytes

As described in the migration guide, to solve this problem, you simply edit the AppServiceProvider. PHP file and set the default string length within the boot method:

use Illuminate\Support\Facades\Schema;

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

After that, everything should work normally.
(PS: The exception explicitly indicates that the maximum length is 767 bytes, and utF8MB4 encodes 4 bytes per character, so 767/4 = 191.75, so set the default length of string to 191 characters. I hope it helps.)

Read More: