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 Zip解压 文件在线解压缩的函数代码
May 26 PHP
MySQL时间字段究竟使用INT还是DateTime的说明
Feb 27 PHP
php连接函数implode与分割explode的深入解析
Jun 26 PHP
PHP中比较两个字符串找出第一个不同字符位置例子
Apr 08 PHP
php表单提交与$_POST实例分析
Jan 26 PHP
PHP中addcslashes与stripcslashes函数用法分析
Jan 07 PHP
10个值得深思的PHP面试题
Nov 14 PHP
thinkPHP框架中执行事务的方法示例
May 31 PHP
PHP实现redis限制单ip、单用户的访问次数功能示例
Jun 16 PHP
PHP开发的文字水印,缩略图,图片水印实现类与用法示例
Apr 12 PHP
php + WebUploader实现图片批量上传功能
May 06 PHP
Yii框架小部件(Widgets)用法实例详解
May 15 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
php车辆违章查询数据示例
2016/10/14 PHP
PHP实现类似题库抽题效果
2018/08/16 PHP
Aster vs Newbee BO3 第三场2.18
2021/03/10 DOTA
javascript call和apply方法
2008/11/24 Javascript
JavaScript 入门基础知识 想学习js的朋友可以参考下
2009/12/26 Javascript
javascript 事件处理程序介绍
2012/06/27 Javascript
使用jQuery validate 验证注册表单实例演示
2013/03/25 Javascript
Js(JavaScript)中,弹出是或否的选择框示例(confirm用法的实例分析)
2013/07/09 Javascript
JavaScript实现url地址自动检测并添加URL链接示例代码
2013/11/12 Javascript
基于jQuery实现点击弹出层实例代码
2016/01/01 Javascript
详解Node.Js如何处理post数据
2016/09/19 Javascript
第一次接触神奇的前端框架vue.js
2016/12/01 Javascript
原生js实现下拉框功能(支持键盘事件)
2017/01/13 Javascript
angular+bootstrap的双向数据绑定实例
2017/03/03 Javascript
ES5 ES6中Array对象去除重复项的方法总结
2017/04/27 Javascript
webpack3+React 的配置全解
2017/08/21 Javascript
vue2利用Bus.js如何实现非父子组件通信详解
2017/08/25 Javascript
JS Input里添加小图标的两种方法
2017/11/11 Javascript
利用adb shell和node.js实现抖音自动抢红包功能(推荐)
2018/02/22 Javascript
浅谈vue首屏加载优化
2018/06/28 Javascript
用node开发并发布一个cli工具的方法步骤
2019/01/03 Javascript
Vue表单之v-model绑定下拉列表功能
2019/05/14 Javascript
js中apply和call的理解与使用方法
2019/11/27 Javascript
Javascript Worker子线程代码实例
2020/02/20 Javascript
[38:21]2018DOTA2亚洲邀请赛3月30日 小组赛A组 LGD VS Newbee
2018/03/31 DOTA
[01:03:37]Secret vs VGJ.S Supermajor小组赛C组 BO3 第二场 6.3
2018/06/04 DOTA
python正则表达式面试题解答
2020/04/28 Python
浅谈Python小波分析库Pywavelets的一点使用心得
2019/07/09 Python
TensorFlow2.0:张量的合并与分割实例
2020/01/19 Python
Python使用configparser库读取配置文件
2020/02/22 Python
L’Artisan Parfumeur官网:法国香水品牌
2020/08/11 全球购物
校领导推荐信
2013/11/01 职场文书
工作决心书
2014/03/11 职场文书
中学生家长评语大全
2014/04/16 职场文书
2014年妇幼卫生工作总结
2014/12/09 职场文书
2016年大学生就业指导课心得体会
2015/10/09 职场文书