Home > Article > PHP Framework > laravel database migration error
(1) Laravel 5.4 or later has changed the default database character set, and now utf8mb4 includes support for storing emojis. If you are running MySQL v5.7.7 or higher, you don't need to do anything.
(2) When you try to run the migrations command on some MariaDB or some older versions of MySQL, you may encounter the following error:Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
[The specified key is too long, the maximum key length is 767 bytes, because the default string length of laravel is 767 bytes, so you have to configure it manually. 】
<?php namespace App\Providers; // 导入Schema类 use Illuminate\Support\Facades\Schema; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { public function boot() { // 在app/providers/AppServiceProvider.php中boot方法中加上 Schema::defaultStringLength(191); } }
For more Laravel related technical articles, please visit the Laravel Tutorial column to learn!
The above is the detailed content of laravel database migration error. For more information, please follow other related articles on the PHP Chinese website!