Home >Database >Mysql Tutorial >How to Resolve the 'Specified Key Was Too Long' Error in Laravel Migrations?

How to Resolve the 'Specified Key Was Too Long' Error in Laravel Migrations?

Barbara Streisand
Barbara StreisandOriginal
2024-12-17 01:57:24204browse

How to Resolve the

Troubleshooting "Specified Key Was Too Long" Migration Error in Laravel

When encountering the error "Specified key was too long" during migrations with Laravel, particularly while executing the "make:auth" command, it's indicative of a key length issue.

Resolution:

According to Laravel documentation, a straightforward fix is to modify your /app/Providers/AppServiceProvider.php file:

use Illuminate\Support\Facades\Schema;

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Schema::defaultStringLength(191);
}

Alternatively, the "innodb_large_prefix" option can be enabled in your database. Refer to your database's documentation for detailed instructions on how to activate this option.

The above is the detailed content of How to Resolve the 'Specified Key Was Too Long' Error in Laravel Migrations?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn