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 at(@)符号的用法简介
Jul 11 PHP
php max_execution_time执行时间问题
Jul 17 PHP
php foreach正序倒序输出示例代码
Jul 01 PHP
浅谈PHP正则表达式中修饰符/i, /is, /s, /isU
Oct 21 PHP
php判断当前操作系统类型
Oct 28 PHP
PHP实现求两个字符串最长公共子串的方法示例
Nov 17 PHP
php5.x禁用eval的操作方法
Oct 19 PHP
PDO::_construct讲解
Jan 27 PHP
PHP正则验证字符串是否为数字的两种方法并附常用正则
Feb 27 PHP
对laravel in 查询的使用方法详解
Oct 09 PHP
关于Yii2框架跑脚本时内存泄漏问题的分析与解决
Dec 01 PHP
TP5框架使用QueryList采集框架爬小说操作示例
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
jquery animate图片模向滑动示例代码
2011/01/26 Javascript
jquery each()源代码
2011/02/14 Javascript
JavaScript中的变量声明早于赋值分析
2012/03/01 Javascript
解决Extjs上传图片无法预览的解决方法
2012/03/22 Javascript
关于全局变量和局部变量的那些事
2013/01/11 Javascript
只需20行代码就可以写出CSS覆盖率测试脚本
2013/04/24 Javascript
简介JavaScript中的getSeconds()方法的使用
2015/06/10 Javascript
JS实现n秒后自动跳转的两种方法
2020/11/30 Javascript
jQuery实现产品对比功能附源码下载
2016/08/09 Javascript
Vue.js 递归组件实现树形菜单(实例分享)
2016/12/21 Javascript
原生JS改变透明度实现轮播效果
2017/03/24 Javascript
详解Vue中watch的高级用法
2018/05/02 Javascript
vue异步加载高德地图的实现
2018/06/19 Javascript
layui中使用jquery控制radio选中事件的示例代码
2018/08/15 jQuery
详解JS判断页面是在手机端还是在PC端打开的方法
2019/04/26 Javascript
vue filter 完美时间日期格式的代码
2019/08/14 Javascript
python生成指定尺寸缩略图的示例
2014/05/07 Python
python实现2048小游戏
2015/03/30 Python
将Django框架和遗留的Web应用集成的方法
2015/07/24 Python
Python3安装Pymongo详细步骤
2017/05/26 Python
Python基于lxml模块解析html获取页面内所有叶子节点xpath路径功能示例
2018/05/16 Python
对pandas中to_dict的用法详解
2018/06/05 Python
解决pyqt5中QToolButton无法使用的问题
2019/06/21 Python
Django文件存储 自己定制存储系统解析
2019/08/02 Python
python通过对字典的排序,对json字段进行排序的实例
2020/02/27 Python
win10下opencv-python特定版本手动安装与pip自动安装教程
2020/03/05 Python
Python生成并下载文件后端代码实例
2020/08/31 Python
解决selenium+Headless Chrome实现不弹出浏览器自动化登录的问题
2021/01/09 Python
html5实现canvas阴影效果示例
2014/05/07 HTML / CSS
一年级语文教学反思
2014/02/13 职场文书
2015年世界无烟日演讲稿
2015/03/18 职场文书
2016年大学生寒假社会实践心得体会
2015/10/09 职场文书
中小学教师继续教育心得体会
2016/01/19 职场文书
表扬稿表扬信的格式及范文
2019/06/24 职场文书
CSS的class与id常用的命名规则
2021/05/18 HTML / CSS
Windows下redis下载、redis安装及使用教程
2021/06/02 Redis