当前位置:网站首页>laravel table migration error [easy to understand]
laravel table migration error [easy to understand]
2022-08-09 23:13:00 【The whole stack programmer webmaster】
Hello everyone, meet again, I'm your friend Quanstack Jun.
error infomation:
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error oraccess violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))at D:\WWW\test\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664660| // If an exception occurs when attempting to run a query, we'll format the error661| // message to include the bindings with SQL, which will make this exception a662| // 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), $e666| );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:4582 PDOStatement::execute()D:\WWW\test\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458Please use the argument -v to see more details.
Solution: Index length & Mysql / MariaDB Laravel uses utf8mb4 encoding by default, which supports storing emojis in the database.If you are creating an index on a MySQL version lower than 5.7.7 or MariaDB version lower than 10.2.2, then you need to manually configure the default string length for database migrations.That is, call the Schema::defaultStringLength method in AppServiceProvider to configure it:
use Illuminate\Support\Facades\Schema;/** * Boot any application service * * @return void */public function boot(){Schema::defaultStringLength(191);}
Publisher: Full-stack programmer, please indicate the source: https://javaforall.cn/105807.htmlOriginal link: https://javaforall.cn
边栏推荐
- np中的round函数,ceil函数与floor函数
- AI Knows Everything: Building and Deploying a Sign Language Recognition System from Zero
- Unity_物体自转
- LeetCode Daily Question (321. Create Maximum Number)
- Tensorflow中使用convert_to_tensor去指定数据的类型
- Wps下划线怎么弄?Wps添加下划线的最全方法
- 消防安全培训|“蓝朋友”,开课了!
- TF中使用zeros(),ones(), fill()方法生成数据
- Jensen (琴生) 不等式
- STC8H development (15): GPIO drive Ci24R1 wireless module
猜你喜欢
[Graphic and textual] How to reinstall Win7 system
【泛型编程】模板全详解
windos安装Mysql8.0,及解决重新登录异常问题 ERROR 1045 (28000)
Puyuan Jingdian turned losses into profits in the first half of the year, and high-end products continued to develop!Are you optimistic about "Huawei" in the instrument industry?
[corctf 2022] 部分
knn到底咋回事?
APP自动化测试框架-UiAutomator2基础入门
Don't tell me to play, I'm taking the PMP exam: what you need to know about choosing an institution for the PMP exam
Word文档怎么输入无穷大符号∞
poj 3070 Fibonacci(简单矩阵连乘)
随机推荐
Reinforcement Learning Weekly Issue 57: DL-DRL, FedDRL & Deep VULMAN
mysql多表左链接查询
小黑leetcode之旅:94. 二叉树的中序遍历(补充Morris 中序遍历)
Daily practice of PMP | Do not get lost in the exam -8.8 (including agility + multiple choice)
Don't use array.length-1 to get the last item of the array
Skywalking系列学习之Trace Profiling源码分析
【stack】【queue】【priority_queue】【deque】Detailed explanation
Unity2D_线框材质
json事例
同步锁synchronized追本溯源
LoRa无线技术在物联网应用市场的概况和发展
几种绘制时间线图的方法
编程语言中,取余和取模的区别
场效应管Mosfet之雷卯Leiditech对应英飞凌Infineon
SecureCRT强制卸载
别叫我玩,我要考PMP:考PMP选择机构需要了解的那些事儿
【stack】【queue】【priority_queue】【deque】详解
SecureCRT 设置超时自动断开连接时长
TF生成均匀分布的tensor
Tensorflow模型整体构建流程