[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too l
ong; max key length is 767 bytes (SQL: alter table `users` add unique `users_em
ail_unique`(`email`))
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too l
ong; max key length is 767 bytes
The easier way to resolve this:
Solution 1:
// config/database.php 'mysql' => [ // ... // Lets stick to utf-8 until we get MySql 5.7.x on server 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', ], Just change the charset, dont go with mb4. Solution 2:
As outlined in the Migrations guide to fix this all you have to do is edit your AppServiceProvider.php
file and inside the boot
method set a default string length:
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
Leave a Reply