导航栏

文章

  • 首页
  • 查看历史

导航栏

  • 登陆
    • QQ登陆 微博登陆
  • 其他
    • 图标库
  • 夜间模式
  • 退出登录

【亲测】laravel迁移出错Syntax error or access violation: 1071 Specified key was too long【亲测】


作者:科技小锅盖             时间:2022-4-15 14:50             站长QQ:1540217035

在使用laravel框架开发php时我们可以使用laravel的迁移机制来快速的创建表及填充数据今天在使用laravel的时候执行php artisan migrate时报错了SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length于是百度解决方法修改config/database.php文件找到mysql配置项将

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

修改为

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

或者在appProvidersAppServiceProvider中调用Schema::defaultStringLength方法来实现配置。

use Illuminate\Support\Facades\Schema;/** Bootstrap any application services.** @return void*/public function boot(){   Schema::defaultStringLength(191);}



推荐

【亲测】laravel5.6.x - 8.x 数据表生成迁移文件

2022-02-08 18:21:08

iQOO10系列两款新品谁更值得买?

2022-07-21 09:37:57

【亲测】vim -文件修改指令【亲测】

2022-10-08 19:46:33

【亲测】Docker 安装使用 【亲测】

2021-07-16 16:09:45

科技小锅盖图库分享更新啦

2021-08-17 11:43:22

imagettftext(): Could not find/open font 搞定

2023-03-17 18:16:00

【亲测】lumen 异步队列 注意事项 【亲测】

2021-05-14 11:18:36

【亲测】Laravel的这10个用法总结【亲测】

2021-08-13 17:33:47

【亲测】Layui 子父框弹窗传值解决办法【亲测】

2020-07-24 11:29:00

iPhone 12e再次曝光,售价或不到4000人民币,你信吗!

2020-07-29 13:25:03

陕ICP备2021003534号-1 科技小锅盖 保留所有权利 网站地图 站长QQ:1540217035
    友情链接:
  • 米醋儿
  • 笔墨