当前位置:网站首页>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
边栏推荐
- 编程语言中,取余和取模的区别
- [Graphic and textual] How to reinstall Win7 system
- 6 g underwater channel modeling were summarized based on optical communication
- Photometric Stereo 光度立体法三维重建
- 【泛型编程】模板全详解
- Skywalking系列学习之Trace Profiling源码分析
- MySQL慢查询的多个原因
- Cholesterol-PEG-Thiol,CLS-PEG-SH,胆固醇-聚乙二醇-巯基用于改善溶解度
- Install Mysql8.0 on windos, and solve the problem of re-login exception ERROR 1045 (28000)
- [corctf 2022] section
猜你喜欢

Byte side: Can TCP and UDP use the same port?

Install Mysql8.0 on windos, and solve the problem of re-login exception ERROR 1045 (28000)

Jmeter 使用正则表达式提取器将返回值全部保存到一个文件中

访问控制知识

筑牢安全防线 鹤壁经济技术开发区开展安全生产培训

UE4_定序器控制蓝图对象

蓝牙模块的分类和对应的属性特点

微软word怎么转换成pdf文件?微软word转换为pdf格式的方法

LoRa Basics无线通信技术和应用案例详解

Excel如何打出正负号?Excel打出正负号的方法
随机推荐
hdu 1503 Advanced Fruits(最长公共子序列的应用)
RHEL7系统修复rm -rf /boot /etc/fstab
编程时请选择正确的输入法,严格区分中英文
hdu 3341 Lost's revenge(dp+Ac自动机)
[Deep learning] pix2pix GAN theory and code implementation
没有 accept,我可以建立 TCP 连接吗?
windos安装Mysql8.0,及解决重新登录异常问题 ERROR 1045 (28000)
什么是源文件?
Install Mysql8.0 on windos, and solve the problem of re-login exception ERROR 1045 (28000)
CMake 安装升级更高版本
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?
Reverse Analysis of Unknown Cryptographic Protocol Based on Network Data Flow
Access Characteristics of Constructor under Inheritance Relationship
MySQL慢查询的多个原因
matlab neural network ANN classification
Next second data: the transformation of the modern data stack brought about by the integration of lake and warehouse has begun
基于网络数据流的未知密码协议逆向分析
Jmeter 使用正则表达式提取器将返回值全部保存到一个文件中
Don't use array.length-1 to get the last item of the array
小黑leetcode清爽雨天之旅,刚吃完宇飞牛肉面、麻辣烫和啤酒:112. 路径总和