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正则表达匹配中文问题分析小结
Mar 25 PHP
分享一则PHP定义函数代码
Feb 26 PHP
php准确计算复活节日期的方法
Apr 18 PHP
centos 7.2下搭建LNMP环境教程
Nov 20 PHP
基于ThinkPHP实现的日历功能实例详解
Apr 15 PHP
php中请求url的五种方法总结
Jul 13 PHP
Laravel 5.5基于内置的Auth模块实现前后台登陆详解
Dec 21 PHP
ThinkPHP整合datatables实现服务端分页的示例代码
Feb 10 PHP
PHP微商城开源代码实例
Mar 27 PHP
PHP保存Base64图片base64_decode的问题整理
Nov 04 PHP
PHP图像处理 imagestring添加图片水印与文字水印操作示例
Feb 06 PHP
php远程请求CURL实例教程(爬虫、保存登录状态)
Dec 10 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
在Windows版的PHP中使用ADO
2006/10/09 PHP
php+mysql不用递归实现的无限级分类实例(非递归)
2014/07/08 PHP
PHP实现的简单日历类
2014/11/29 PHP
PHP几个实用自定义函数小结
2016/01/25 PHP
tp5框架使用composer实现日志记录功能示例
2019/01/10 PHP
dojo 之基础篇(三)之向服务器发送数据
2007/03/24 Javascript
用JavaScript实现UrlEncode和UrlDecode的脚本代码
2008/07/23 Javascript
JavaScript null和undefined区别分析
2009/10/14 Javascript
Jquery跨域获得Json时invalid label错误的解决办法
2011/01/11 Javascript
使用JavaScript 实现对象 匀速/变速运动的方法
2013/05/08 Javascript
jQuery之尺寸调整组件的深入解析
2013/06/19 Javascript
Js注册协议倒计时的小例子
2013/06/24 Javascript
js传中文参数controller里获取参数乱码问题解决方法
2014/01/03 Javascript
fmt:formatDate的输出格式详解
2014/01/09 Javascript
jQuery中Ajax的load方法详解
2015/01/14 Javascript
深入理解JavaScript函数参数(推荐)
2016/07/26 Javascript
AngularJS中下拉框的基本用法示例
2017/10/11 Javascript
JS实现数组简单去重及数组根据对象中的元素去重操作示例
2018/01/05 Javascript
Vue初始化中的选项合并之initInternalComponent详解
2020/06/11 Javascript
Element InputNumber 计数器的实现示例
2020/08/03 Javascript
Vue 构造选项 - 进阶使用说明
2020/08/14 Javascript
python显示天气预报
2014/03/02 Python
Python开发如何在ubuntu 15.10 上配置vim
2016/01/25 Python
[原创]pip和pygal的安装实例教程
2017/12/07 Python
python如何在列表、字典中筛选数据
2018/03/19 Python
numpy实现合并多维矩阵、list的扩展方法
2018/05/08 Python
python语言线程标准库threading.local解读总结
2019/11/10 Python
opencv3/C++ 平面对象识别&透视变换方式
2019/12/11 Python
介绍一下代理模式(Proxy)
2014/10/17 面试题
应届生保险求职信
2013/11/11 职场文书
满月酒主持词
2014/03/27 职场文书
个人租房协议书
2014/04/09 职场文书
高中班主任评语大全
2014/04/25 职场文书
文艺晚会开场白
2015/05/29 职场文书
Oracle 区块链表创建过程详解
2021/05/15 Oracle
纯html+css实现奥运五环的示例代码
2021/08/02 HTML / CSS