当前位置:网站首页>laravel 表迁移报错[通俗易懂]
laravel 表迁移报错[通俗易懂]
2022-08-09 20:51:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
error infomation:
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 `use
rs` add unique `users_email_unique`(`email`))
at D:\WWW\test\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes")
D:\WWW\test\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
2 PDOStatement::execute()
D:\WWW\test\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
Please use the argument -v to see more details.
解决: 索引长度 & Mysql / MariaDB Laravel 默认使用 utf8mb4 编码,它支持在数据库中储存 emojis 。如果你是在版本低于 5.7.7 的 MySQL 或者版本低于 10.2.2 的 MariaDB 上创建索引,那你就需要手动配置数据库迁移的默认字符串长度。 即在 AppServiceProvider 中调用 Schema::defaultStringLength 方法来配置它:
use Illuminate\Support\Facades\Schema;
/** * 引导任何应用程序服务 * * @return void */
public function boot()
{
Schema::defaultStringLength(191);
}
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/105807.html原文链接:https://javaforall.cn
边栏推荐
猜你喜欢
visual studio 2022调试技巧介绍
DSPE-PEG-Silane,DSPE-PEG-SIL,磷脂-聚乙二醇-硅烷修饰二氧化硅颗粒用
企业数据打通有什么好处?不同行业怎么解决数据打通难题?
matlab neural network ANN classification
Wps下划线怎么弄?Wps添加下划线的最全方法
windos安装Mysql8.0,及解决重新登录异常问题 ERROR 1045 (28000)
Install Mysql8.0 on windos, and solve the problem of re-login exception ERROR 1045 (28000)
DSPE-PEG-Azide,DSPE-PEG-N3,磷脂-聚乙二醇-叠氮可和DBCO直接反应
knn到底咋回事?
buuctf (Adventure 2)
随机推荐
PMP每日一练 | 考试不迷路-8.8(包含敏捷+多选)
Visual studio 2022 debugging skills introduction
PMP每日一练 | 考试不迷路-8.9(包含敏捷+多选)
Redis 大的情况下,key 要如何处理?
[corctf 2022] section
DSPE-PEG-Azide,DSPE-PEG-N3,磷脂-聚乙二醇-叠氮可和DBCO直接反应
SecureCRT背景配色
Word怎么制作双面席卡?使用Word制作双面席卡方法
【泛型编程】模板全详解
supervisor 命令操作大全「建议收藏」
Word第一页不要页眉怎么设置?设置Word首页不要页眉方法教程
【随笔】致19期的小伙伴们
Definition and Basic Operations of Linear Tables
Optimization of SQL Statements and Indexes
基于模糊PID控制器的水温控制系统仿真
SecureCRT强制卸载
Access Characteristics of Constructor under Inheritance Relationship
What are the benefits of enterprise data integration?How do different industries solve the problem of data access?
Application of Acrel5000web Energy Consumption System in a College-Susie Week
自监督学习 —— MoCo v2