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 相关文章推荐
初探PHP5
Oct 09 PHP
判断PHP数组是否为空的代码
Sep 08 PHP
推荐5款跨平台的PHP编辑器
Dec 25 PHP
php命令行(cli)模式下报require 加载路径错误的解决方法
Nov 23 PHP
PHP实现搜索地理位置及计算两点地理位置间距离的实例
Jan 08 PHP
Laravel 5.3 学习笔记之 错误&日志
Aug 28 PHP
php 三大特点:封装,继承,多态
Feb 19 PHP
深入理解PHP中mt_rand()随机数的安全
Oct 12 PHP
PHP通过bypass disable functions执行系统命令的方法汇总
May 02 PHP
php高清晰度无损图片压缩功能的实现代码
Dec 09 PHP
解决laravel 表单提交-POST 异常的问题
Oct 15 PHP
php设计模式之策略模式实例分析【星际争霸游戏案例】
Mar 26 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
thinkphp3.2同时连接两个数据库的简单方法
2019/08/13 PHP
一段批量给页面上的控件赋值js
2010/06/19 Javascript
javascript 触发HTML元素绑定的函数
2010/09/11 Javascript
使用js获取图片原始尺寸
2014/12/03 Javascript
jQuery实现鼠标经过时出现隐藏层文字链接的方法
2015/10/12 Javascript
JavaScript几种数组去掉重复值的方法推荐
2016/04/12 Javascript
js接收并转化Java中的数组对象的方法
2016/08/11 Javascript
Node.js 实现简单小说爬虫实例
2016/11/18 Javascript
解决AngualrJS页面刷新导致异常显示问题
2017/04/20 Javascript
Vue.js 点击按钮显示/隐藏内容的实例代码
2018/02/08 Javascript
vue .sync修饰符的使用详解
2018/06/15 Javascript
JS实现Cookie读、写、删除操作工具类示例
2018/08/28 Javascript
泛谈JS逻辑判断选择器 || &&
2019/05/24 Javascript
ES6的异步终极解决方案分享
2019/07/11 Javascript
nodejs中各种加密算法的实现详解
2019/07/11 NodeJs
js实现带箭头的进度流程
2020/03/26 Javascript
python正则表达式去掉数字中的逗号(python正则匹配逗号)
2013/12/25 Python
python访问sqlserver示例
2014/02/10 Python
Python与R语言的简要对比
2017/11/14 Python
django文档学习之applications使用详解
2018/01/29 Python
Django1.9 加载通过ImageField上传的图片方法
2018/05/25 Python
python 调用有道api接口的方法
2019/01/03 Python
Python简单基础小程序的实例代码
2019/04/28 Python
python+opencv实现摄像头调用的方法
2019/06/22 Python
Django 自定义分页器的实现代码
2019/11/24 Python
python logging.basicConfig不生效的原因及解决
2020/02/20 Python
matplotlib交互式数据光标mpldatacursor的实现
2021/02/03 Python
CSS3 实现的火焰动画
2020/12/07 HTML / CSS
html5版canvas自由拼图实例
2014/10/15 HTML / CSS
初中语文教学反思
2014/02/02 职场文书
党员公开承诺书内容
2014/05/20 职场文书
扬州个园导游词
2015/02/06 职场文书
加薪通知
2015/04/25 职场文书
人民的好儿女观后感
2015/06/18 职场文书
保护动物的宣传语
2015/07/13 职场文书
Python字符串格式化方式
2022/04/07 Python