Laravel教程中数据迁移命令出错,提示 specified key was too long的解决办法

执行migrate命令

php artisan migrate

出现错误

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 unique 'users_email_unique'<'email'>>

改一下这两个参数,搞定(数据库的字符集和排序规则也需要作同样修改)

config/database.php
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',

猜你喜欢

转载自blog.csdn.net/loverzai/article/details/80663303
今日推荐