Home >Database >Mysql Tutorial >Laravel 5.4 Migration Error: How to Fix 'Specified Key Was Too Long'?
Problem Encountered:
When attempting to use the make:auth command in Laravel 5.4, a database migration error occurs:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
Solution:
To resolve this issue, which is commonly encountered when using the default MySQL InnoDB engine, there are two approaches:
AppServiceProvider Method:
use Illuminate\Support\Facades\Schema; /** * Bootstrap any application services. * * @return void */ public function boot() { Schema::defaultStringLength(191); }
MySQL Server Configuration:
Alternatively, you can modify the MySQL server configuration to enable the innodb_large_prefix option. The specific instructions for enabling this option vary depending on your database setup. Refer to MySQL documentation for guidance.
Additional Notes:
The above is the detailed content of Laravel 5.4 Migration Error: How to Fix 'Specified Key Was Too Long'?. For more information, please follow other related articles on the PHP Chinese website!