问题:
执行迁移文件: php artisan migrate后报错
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `users` add unique `
users_email_unique`(`email`))
原因:
Laravel 默认使用 utf8mb4 字符,包括支持在数据库存储 。 如果正运行的 MySQL release 版本低于5.7.7 或 MariaDB release版本低于10.2.2 ,应手动配置迁移生成的默认字符串长度
解决办法:
调用 AppServiceProvider.php 中的 Schema::defaultStringLength方法