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在Web开发领域的优势
Oct 09 PHP
PHP中实现进程间通讯
Oct 09 PHP
PHP连接access数据库
Mar 27 PHP
不用mod_rewrite直接用php实现伪静态化页面代码
Oct 04 PHP
php 保留小数点
Apr 21 PHP
深入php数据采集的详解
Jun 02 PHP
一个简洁实用的PHP缓存类完整实例
Jul 26 PHP
php数组添加元素方法小结
Dec 20 PHP
php中使用base HTTP验证的方法
Apr 20 PHP
php中关于长度计算容易混淆的问题分析
May 27 PHP
PHP依赖注入(DI)和控制反转(IoC)详解
Jun 12 PHP
php面向对象程序设计中self与static的区别分析
May 21 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内置访问资源的超时时间 time_out file_get_contents read_file
2013/06/03 PHP
php实现信用卡校验位算法THE LUHN MOD-10示例
2014/05/07 PHP
destoon出现验证码不显示时的紧急处理方法
2014/08/22 PHP
PHP基于GD2函数库实现验证码功能示例
2019/01/27 PHP
jQuery 解析xml文件
2009/08/09 Javascript
xml文档转换工具,附图表例子(hta)
2010/11/17 Javascript
js 连接数据库如何操作数据库中的数据
2012/11/23 Javascript
JavaScript中setAttribute用法介绍
2013/07/20 Javascript
js闭包的用途详解
2014/11/09 Javascript
ECMAScript6函数默认参数
2015/06/12 Javascript
纯javascript代码实现计算器功能(三种方法)
2015/09/07 Javascript
Bootstrap组件系列之福利篇几款好用的组件(推荐)
2016/06/23 Javascript
jQuery 调用WebService 实例讲解
2016/06/28 Javascript
JS实现太极旋转思路分析
2016/12/09 Javascript
微信小程序 数据交互与渲染实例详解
2017/01/21 Javascript
vue在使用ECharts时的异步更新和数据加载详解
2017/11/22 Javascript
JS抛物线动画实例制作
2018/02/24 Javascript
如何优雅地在vue中添加权限控制示例详解
2019/03/07 Javascript
详解vue项目中调用百度地图API使用方法
2019/04/25 Javascript
JS图片懒加载技术实现过程解析
2020/07/27 Javascript
vue中defineProperty和Proxy的区别详解
2020/11/30 Vue.js
从零学Python之引用和类属性的初步理解
2014/05/15 Python
使用Python读写及压缩和解压缩文件的示例
2016/07/08 Python
Python3 queue队列模块详细介绍
2018/01/05 Python
pandas进行数据的交集与并集方式的数据合并方法
2018/06/27 Python
Python文件打开方式实例详解【a、a+、r+、w+区别】
2019/03/30 Python
设计师大码女装:11 Honoré
2020/05/03 全球购物
C#笔试题
2015/07/14 面试题
什么是虚拟内存?虚拟内存有什么优势?
2016/02/09 面试题
short s1 = 1; s1 = s1 + 1;有什么错? short s1 = 1; s1 += 1;有什么错?
2014/09/26 面试题
教师纪念9.18事件演讲稿范文
2014/09/14 职场文书
2014年标准化工作总结
2014/12/17 职场文书
教育实习指导教师评语
2014/12/31 职场文书
如何把新闻人物写得立体、鲜活?
2019/08/14 职场文书
浅谈Python中的正则表达式
2021/06/28 Python
html网页引入svg图片的4种方式
2022/08/05 HTML / CSS