Description
i recieve that error on the last part of laravel installation wizard how wil i resolve the issue?
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table password_resets add primary key (email))
View Code
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table password_resets add primary key (email))
This error typically occurs when you are using a version of MySQL older than 5.7.7 or MariaDB older than 10.2.2. The issue is related to the default string length used for indexing in Laravel migrations.
Solution:
Change Default String Length in Laravel
Add the following code to your
AppServiceProvider
class in theboot
method:Also make sure to add this Schema namespace at the top:
use Illuminate\Support\Facades\Schema;
phpSchema::defaultStringLength(191);
This code sets the default string length for the Laravel schema builder to 191, which is the maximum length allowed for index keys in MySQL and MariaDB.
0 Likes 1 Comment
Hadayat Niazi Super Admin
If the above problem was solved, please mark this post as solved.