0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

laravel5.4&MySQLでテーブルを作成するときに767 bytesエラー

Posted at

こんなエラー

 [Illuminate\Database\QueryException]                                                                                                                
  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add uniq  
  ue `users_email_unique`(`email`))  



  [Doctrine\DBAL\Driver\PDOException]                                                                              
  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes  
                                                                                                                   

                                                                                                                   
  [PDOException]                                                                                                   
  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes 

ぐぐったら、charsetがutf8mb4というのになっていて1文字が最大4byteだからオーバーするらしい。
既存のテーブルに追加しようと思ってたので、
charsetをutf8にしてmigrateで解決。

database.php
//            'charset' => 'utf8mb4',
//            'collation' => 'utf8mb4_unicode_ci',
            'charset' => 'utf8',
            'collation' => 'utf8_general_ci',
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?