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
Release: 2024-12-17 01:57:24
Original
198 people have browsed it

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);
}
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template