解決Laravel錯誤1071 Specified key was too long的多種方法


If you are using MariaDB or an older version of MySQL, you need to place this code in your AppServiceProvider.php:

use Illuminate\Support\Facades\Schema;  public function boot() {     Schema::defaultStringLength(191); } 

Inside config/database.php, replace this line for mysql

'engine' => null', 

with

'engine' => 'InnoDB ROW_FORMAT=DYNAMIC', 

Instead of setting a limit on your string lenght.Change  database.php which is in config folder where it says

'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 

I changed these to

'charset' => 'utf8', 'collation' => 'utf8_unicode_ci',

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM