laravel5.5报错:1071 Specified key was too long; max key length is 767 bytes
2018-03-12 21:34
417 查看
原因:laravel改变了默认的数据库字符集,现在使用utf8mb4,如果你使用的MySQL数据库高于5.7就不会报错,如果低于该版本就会报错
解决方案:在AppServiceProvider添加代码: Schema::defaultStringLength(191);
完整的代码:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
解决方案:在AppServiceProvider添加代码: Schema::defaultStringLength(191);
完整的代码:
use Illuminate\Support\Facades\Schema;//一定要记得引入Schema /** * Bootstrap any application services. * * @return void */ public function boot() { Schema::defaultStringLength(191); }
相关文章推荐
- 1071-specified-key-was-too-long-max-key-length-is-767-bytes
- MySQL: ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- MySQL: ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- ERROR 1071 (42000) at line 142: Specifiedkey was too long; max key length is 767 bytes
- laravel错误1071 Specified key was too long; max key length is 1000 bytes
- MySQL: ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- 索引长度过长 ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- laravel错误1071 Specified key was too long; max key length is 1000 bytes
- MySQL中ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes错误的处理
- MySQL ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- laravel错误1071 Specified key was too long; max key length is 1000 bytes
- mysql [42000][1071] Specified key was too long; max key length is 767 bytes
- #1071 - Specified key was too long; max key length is 767 bytes
- laravel错误1071 Specified key was too long; max key length is 1000 bytes
- ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- MySQL----ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- MySQL: ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes