Laravel-执行php artisan migrate时报错

1、 Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

报错原因:laravel默认字符串长度为1071,而报错中看出数据库设置了最大是767,所以就报错了

解决方法:

修改app/Providers/AppServiceProvider.php文件中的boot,添加


use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(522);    //自定义字符串长度
}


2、 Base table or view already exists: 1050 Table 'users' already exists
一直提示users表已经存在

解决方法:

直接在Mysql查询里执行:

DROP TABLE IF EXISTS `users`;

删除users表


3、自定义users表名为sys_user时,要注意将api_token里的user也改成sys_user

猜你喜欢

转载自blog.csdn.net/weixin_38682852/article/details/79578168