laravel执行php artisan migrate报错的解决方法


Posted in PHP onOctober 09, 2019

报错一

$ php artisan migrate
 
 Illuminate\Database\QueryException : could not find driver (SQL: select * fr
om information_schema.tables where table_schema = dev_oms and table_name = migra
tions)
 
 at D:\WWW\dev_oms\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 th
is exception a
 662|   // lot more helpful to the developer instead of just the databa
se's errors.
 663|   catch (Exception $e) {
 > 664|    throw new QueryException(
 665|     $query, $this->prepareBindings($bindings), $e
 666|    );
 667|   }
 668|
 
 Exception trace:
 
 1 PDOException::("could not find driver")
  D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connectors
\Connector.php:68
 
 2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=dev_oms", "root",
"root", [])
  D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connectors
\Connector.php:68
 
 Please use the argument -v to see more details.

原因是php.ini 扩展"php_pdo_mysql.dll"没开启

laravel执行php artisan migrate报错的解决方法

报错二

$ php artisan migrate
Migration table created successfully.
 
 Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access
 violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: a
lter table `users` add unique `users_email_unique`(`email`))
 
 at D:\WWW\dev_oms\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 th
is exception a
 662|   // lot more helpful to the developer instead of just the databa
se'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 Sp
ecified key was too long; max key length is 767 bytes")
  D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connection
.php:458
 2 PDOStatement::execute()
  D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connection
.php:458
 Please use the argument -v to see more details.

数据库编码改为utf8mb4

laravel执行php artisan migrate报错的解决方法

报错三

$ php artisan migrate
Migration table created successfully.
 
 Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access
 violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: a
lter table `users` add unique `users_email_unique`(`email`))
 
 at D:\WWW\dev_oms\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 th
is exception a
 662|   // lot more helpful to the developer instead of just the databa
se'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 Sp
ecified key was too long; max key length is 767 bytes")
  D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connection
.php:458
 2 PDOStatement::execute()
  D:\WWW\dev_oms\vendor\laravel\framework\src\Illuminate\Database\Connection
.php:458
 Please use the argument -v to see more details.

加上两行代码即可

laravel执行php artisan migrate报错的解决方法

以上这篇laravel执行php artisan migrate报错的解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

PHP 相关文章推荐
php mssql扩展SQL查询中文字段名解决方法
Oct 15 PHP
基于PHP对XML的操作详解
Jun 07 PHP
基于PHP CURL用法的深入分析
Jun 09 PHP
提升PHP性能的21种方法介绍
Jun 25 PHP
使用配置类定义Codeigniter全局变量
Jun 12 PHP
php读取mssql的ntext字段返回值为空的解决方法
Dec 30 PHP
浅析Yii2 gridview实现批量删除教程
Apr 22 PHP
php微信公众平台配置接口开发程序
Sep 22 PHP
PHP实现RTX发送消息提醒的实例代码
Jan 03 PHP
tp5实现微信小程序多图片上传到服务器功能
Jul 16 PHP
laravel实现前后台路由分离的方法
Oct 13 PHP
linux mint下安装phpstorm2020包括JDK部分的教程详解
Sep 17 PHP
解决Laravel 不能创建 migration 的问题
Oct 09 #PHP
Laravel创建数据库表结构的例子
Oct 09 #PHP
关于laravel 数据库迁移中integer类型是无法指定长度的问题
Oct 09 #PHP
Laravel 创建指定表 migrate的例子
Oct 09 #PHP
laravel批量生成假数据的方法
Oct 09 #PHP
解决laravel5中auth用户登录其他页面获取不到登录信息的问题
Oct 08 #PHP
对laravel的session获取与存取方法详解
Oct 08 #PHP
You might like
下载文件的点击数回填
2006/10/09 PHP
PHP程序员简单的开展服务治理架构操作详解(二)
2020/05/14 PHP
PHP并发场景的三种解决方案代码实例
2021/02/27 PHP
JavaScript省市联动实现代码
2014/02/15 Javascript
前端必备神器 Snap.svg 弹动效果
2014/11/10 Javascript
js实现键盘控制DIV移动的方法
2015/01/10 Javascript
利用jQuery实现漂亮的圆形进度条倒计时插件
2015/09/30 Javascript
利用bootstrapValidator验证UEditor
2016/09/14 Javascript
jquery实现刷新随机变化样式特效(tag标签样式)
2017/02/03 Javascript
AngularJs+Bootstrap实现漂亮的计算器
2017/08/10 Javascript
vue如何使用 Slot 分发内容实例详解
2017/09/05 Javascript
Angular实现点击按钮后在上方显示输入内容的方法
2017/12/27 Javascript
Angular4集成ng2-file-upload的上传组件
2018/03/14 Javascript
vue 中filter的多种用法
2018/04/26 Javascript
微信小程序开发注意指南和优化实践(小结)
2019/06/21 Javascript
js面向对象封装级联下拉菜单列表的实现步骤
2021/02/08 Javascript
[01:10:58]Spirit vs NB Supermajor小组赛 A组败者组决赛 BO3 第二场 6.2
2018/06/03 DOTA
python基本语法练习实例
2017/09/19 Python
python 调用c语言函数的方法
2017/09/29 Python
Python操作Oracle数据库的简单方法和封装类实例
2018/05/07 Python
python 提取key 为中文的json 串方法
2018/12/31 Python
python爬虫 基于requests模块的get请求实现详解
2019/08/20 Python
python调用摄像头的示例代码
2020/09/28 Python
分布式全文检索引擎ElasticSearch原理及使用实例
2020/11/14 Python
最新pycharm安装教程
2020/11/18 Python
python3爬虫中多线程的优势总结
2020/11/24 Python
香港草莓网:Strawberrynet香港
2019/05/10 全球购物
OnePlus加拿大官网:中国国际化手机品牌
2020/10/13 全球购物
静态变量和实例变量的区别
2015/07/07 面试题
校园歌手大赛策划书
2014/01/17 职场文书
农村婚礼主持词
2014/03/13 职场文书
大学生村官演讲稿
2014/04/25 职场文书
党员承诺书格式
2014/05/21 职场文书
办公楼租房协议书范本
2014/11/25 职场文书
2015年119消防宣传日活动总结
2015/03/24 职场文书
2015银行年终工作总结范文
2015/05/26 职场文书